purescript-bridge-0.3.0.2: Generate PureScript data types from Haskell data types

Safe HaskellSafe
LanguageHaskell2010

Language.PureScript.Bridge

Synopsis

Documentation

bridgeSumType :: TypeBridge -> SumType -> SumType Source

Translate leaf types in a sum type to match PureScript types.

defaultBridge :: TypeBridge Source

Default bridge for mapping primitive/common types: You can append your own bridges like this: defaultBridge | myBridge1 | myBridge2

Find examples for bridge definitions in Language.PureScript.Bridge.Primitives and Language.PureScript.Bridge.Tuple.

writePSTypes :: TypeBridge -> FilePath -> [SumType] -> IO () Source

Your entry point to this library and quite likely all you will need. Make sure all your types derive Generic and Typeable. Typeable is not needed from ghc-7.10 on.

Then call writePSTypes like this: let myTypes = [ toSumType (Proxy :: Proxy MyType1) , toSumType (Proxy :: Proxy MyType2) ] writePSTypes defaultBridge "path/to/you/purescript/project" myTypes

You can add new type mappings, like this: myBridge = defaultBridge | mySpecialTypeBridge

Find examples for implementing your own type bridges in: Primitives A real world use case of this library can be found here. Last but not least:

WARNING: This function overwrites files - make backups or use version control!