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 |
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.
purescript-bridge/src/Language/PureScript/Bridge/SumType.hs
Line 63 in a65fd63
purescript-bridge/src/Language/PureScript/Bridge/Printer.hs
Lines 174 to 179 in a65fd63