Safe Haskell | None |
---|---|

Language | Haskell2010 |

Generate Elm type definitions, encoders and decoders from Haskell data types.

## Synopsis

- include :: ToHType a => Proxy a -> GenOption -> Builder
- generateFor :: ElmVersion -> Options -> Text -> Maybe FilePath -> Builder -> Q Exp
- data ElmVersion
- data HType
- = HUDef UDefData
- | HMaybe HType
- | HList HType
- | HPrimitive MData
- | HRecursive MData
- | HExternal (ExInfo HType)

- class ToHType f where
- data ExInfo a = ExInfo {}
- type Builder = State GenConfig ()
- data GenOption
- data PolyConfig

# Documentation

include :: ToHType a => Proxy a -> GenOption -> Builder Source #

Include the elm source for the Haskell type specified by the proxy argument. The second argument decides which components will be included and if the generated type will be polymorphic.

This type holds the type information we get from generics.
Only the `HExternal`

constructor is supposed to be used by the programmer
to implement `ToHType`

instances for entites that are predefined in Elm. A sample can be seen below.

Here, let `MyExtType a b` be a type which has the corresponding type, encoders and decoders predefined in Elm in a module named Lib. Here is how you can implement a ToHType instance for this type so that your other autogenerated types can have fields of type `MyExtType a b`.

instance (ToHType a, ToHType b) => ToHType (MyExtType a b) where toHType _ = do ha <- toHType (Proxy :: Proxy a) hb <- toHType (Proxy :: Proxy b) pure $ HExternal (ExInfo (External, MyExtType) (Just (External, "encodeMyExtType")) (Just (External, "decodeMyExtType")) [ha, hb])

HUDef UDefData | |

HMaybe HType | |

HList HType | |

HPrimitive MData | |

HRecursive MData | |

HExternal (ExInfo HType) |

class ToHType f where Source #

Nothing

toHType :: Proxy f -> HState HType Source #

toHType :: (ToHTArgs (ExtractTArgs f), Generic f, ToHType_ (Rep f)) => Proxy f -> HState HType Source #

## Instances

ToHType () Source # | |

Typeable a => ToHType a Source # | |

ToHType Text Source # | |

ToHType a => ToHType [a] Source # | |

ToHType a => ToHType (Maybe a) Source # | |

(ToHType a, ToHType b) => ToHType (Either a b) Source # | |

(ToHType a1, ToHType a2) => ToHType (a1, a2) Source # | |

(ToHType a1, ToHType a2, ToHType a3) => ToHType (a1, a2, a3) Source # | |

(ToHType a1, ToHType a2, ToHType a3, ToHType a4) => ToHType (a1, a2, a3, a4) Source # | |

(ToHType a1, ToHType a2, ToHType a3, ToHType a4, ToHType a5) => ToHType (a1, a2, a3, a4, a5) Source # | |

(ToHType a1, ToHType a2, ToHType a3, ToHType a4, ToHType a5, ToHType a6) => ToHType (a1, a2, a3, a4, a5, a6) Source # | |

(ToHType a1, ToHType a2, ToHType a3, ToHType a4, ToHType a5, ToHType a6, ToHType a7) => ToHType (a1, a2, a3, a4, a5, a6, a7) Source # | |

Decides which among type definiton, encoder and decoder will be included for a type. The poly config value decides wether the included type definition will be polymorphic.

data PolyConfig Source #

Decides wether the type definition will be polymorphic.

## Instances

Show PolyConfig Source # | |

Defined in Elminator.Lib showsPrec :: Int -> PolyConfig -> ShowS # show :: PolyConfig -> String # showList :: [PolyConfig] -> ShowS # |