Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugging in custom generators for instances #60

Open
anka-213 opened this issue May 18, 2022 · 0 comments
Open

Allow plugging in custom generators for instances #60

anka-213 opened this issue May 18, 2022 · 0 comments

Comments

@anka-213
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant