Skip to content

Generics for Records #49

Description

@BebeSparkelSparkel

I find to be filling in a lot of record fields from the cli parameters and it would be much faster to have some generic way of generating parser code.

data AB f = AB {a :: f Int, b :: f String}

type ProgramType :: Type -> Type
type family ProgramType a

genericOptions :: forall (mkOption :: Symbol -> Symbol) (mkName :: Symbol -> Symbol) p b m a. Generic a => (a -> ParserT p m b) -> ParserT (ProgramType (Rep a) & p) m b)

Which genericOptions @("--" ++) @ID @(AB Maybe) would generate something like

\f ->
  opt @"--a" @"a" $ \a ->
  opt @"--b" @"b" $ \b ->
  f AB {..}

There seems like there could be several versions for Opt Arg Flag.
Does this make sense or is there a better way?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions