optparse-th-0.1.0.0: Like `optparse-generic`, but with `TemplateHaskell` for faster builds
Safe HaskellSafe-Inferred
LanguageHaskell2010

Options.TH

Description

This module is designed to provide a TemplateHaskell alternative to Options.Generic.

Synopsis

Documentation

deriveParseRecord :: Modifiers -> Name -> Q [Dec] Source #

This function derives ParseRecord for you without incurring a Generic dependency.

The main barrier here to fully supporting the library is that the API for ParseRecord does not expose the function that provides modifiers by default. So we can provide an instance of ParseRecord, but we can't provide a replacement of parseRecordWithModifiers, because that function is defined as a top-level that delegates directly to the generic.

parseRecordWithModifiers
    :: (Generic a, GenericParseRecord (Rep a))
    => Modifiers
    -> Parser
parseRecordWithModifiers modifiers =
    fmap GHC.Generics.to (genericParseRecord modifiers)

This means that we need to shift the options to the compile-time site, instead of the runtime site.

Likewise, we cannot provide an instance of Unwrappable, because it's not a class - it's a type alias for Generic stuff. So we need to create a separate top-level function that does the unwrap.

Since: 0.1.0.0