Skip to content

Allow plugging in custom generators for instances #60

@anka-213

Description

@anka-213

AFAICT, currently the list of all the different kinds of instances that can be generated is hard-coded into the printer. I would like to be able to plug in some custom code to generate instances for my types, without needing to fork this library.

data Instance = Encode | EncodeJson | Decode | DecodeJson | Generic | Newtype | Eq | Ord deriving (Eq, Show)

instances :: Switches.Settings -> SumType 'PureScript -> [Text]
instances settings st@(SumType t _ is) = map go is
where
go :: Instance -> Text
go Encode = "instance encode" <> _typeName t <> " :: " <> extras <> "Encode " <> typeInfoToText False t <> " where\n" <>
" encode = genericEncode $ defaultOptions" <> encodeOpts

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