Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class HasElmType a where
- class HasElmDefinition a where
- class HasElmType a => HasElmDecoder value a where
- elmDecoder :: Expression v
- class HasElmType a => HasElmEncoder value a where
- elmEncoder :: Expression v
- class HasElmDecoderDefinition value a where
- class HasElmEncoderDefinition value a where
- newtype Options = Options {
- fieldLabelModifier :: String -> String
- defaultOptions :: Options
- deriveElmTypeDefinition :: forall a. (HasDatatypeInfo a, All2 HasElmType (Code a)) => Options -> Qualified -> Definition
- deriveElmJSONDecoder :: forall a. (HasDatatypeInfo a, HasElmType a, All2 (HasElmDecoder Value) (Code a)) => Options -> Options -> Qualified -> Definition
- deriveElmJSONEncoder :: forall a. (HasDatatypeInfo a, HasElmType a, All2 (HasElmEncoder Value) (Code a)) => Options -> Options -> Qualified -> Definition
- jsonDefinitions :: forall t. (HasElmDefinition t, HasElmEncoderDefinition Value t, HasElmDecoderDefinition Value t) => [Definition]
Classes
class HasElmType a where Source #
Represents that the corresponding Elm type for the Haskell type a
is
.elmType
@a
This class has a default instance for types that satisfy HasElmDefinition
,
which refers to the name of that definition.
Nothing
Instances
HasElmType Bool Source # | |
Defined in Language.Haskell.To.Elm | |
HasElmType Char Source # | |
Defined in Language.Haskell.To.Elm | |
HasElmType Double Source # | |
Defined in Language.Haskell.To.Elm | |
HasElmType Int Source # | |
Defined in Language.Haskell.To.Elm | |
HasElmType Text Source # | |
Defined in Language.Haskell.To.Elm | |
HasElmType UTCTime Source # | |
Defined in Language.Haskell.To.Elm | |
HasElmType a => HasElmType [a] Source # | |
Defined in Language.Haskell.To.Elm | |
HasElmType a => HasElmType (Maybe a) Source # | |
Defined in Language.Haskell.To.Elm | |
(HasElmType a, HasElmType b) => HasElmType (a, b) Source # | |
Defined in Language.Haskell.To.Elm |
class HasElmDefinition a where Source #
Represents that we can generate the definition for the Elm type that
corresponds to a
using
.elmDefinition
@a
See deriveElmTypeDefinition
for a way to automatically derive elmDefinition
.
class HasElmType a => HasElmDecoder value a where Source #
Represents that the Elm type that corresponds to a
has a decoder from
value
, namely
.elmDecoder
@value @a
This class has a default instance for types that satisfy
HasElmDecoderDefinition
, which refers to the name of that definition.
Nothing
elmDecoder :: Expression v Source #
elmDecoder :: HasElmDecoderDefinition value a => Expression v Source #
Instances
class HasElmType a => HasElmEncoder value a where Source #
Represents that the Elm type that corresponds to a
has an encoder into
value
, namely
.elmEncoder
@value @a
This class has a default instance for types that satisfy
HasElmEncoderDefinition
, which refers to the name of that definition.
Nothing
elmEncoder :: Expression v Source #
elmEncoder :: HasElmEncoderDefinition value a => Expression v Source #
Instances
class HasElmDecoderDefinition value a where Source #
Represents that we can generate the Elm decoder definition from value
for the Elm type that corresponds to a
.
See deriveElmJSONDecoder
for a way to automatically derive
elmDecoderDefinition
when value =
.Value
class HasElmEncoderDefinition value a where Source #
Represents that we can generate the Elm encoder definition into value
for the Elm type that corresponds to a
.
See deriveElmJSONEncoder
for a way to automatically derive
elmEncoderDefinition
when value =
.Value
Derivers
Elm code generation options
Options | |
|
deriveElmTypeDefinition :: forall a. (HasDatatypeInfo a, All2 HasElmType (Code a)) => Options -> Qualified -> Definition Source #
Automatically create an Elm definition given a Haskell type.
This is suitable for use as a HasElmDefinition
instance:
instanceHasElmDefinition
MyType whereelmDefinition
=deriveElmTypeDefinition
@MyTypedefaultOptions
"Api.MyType.MyType"
deriveElmJSONDecoder :: forall a. (HasDatatypeInfo a, HasElmType a, All2 (HasElmDecoder Value) (Code a)) => Options -> Options -> Qualified -> Definition Source #
Automatically create an Elm JSON decoder definition given a Haskell type.
This is suitable for use as a
instance:HasElmDecoderDefinition
Value
instanceHasElmDecoderDefinition
Value
MyType whereelmDecoderDefinition
=deriveElmJSONDecoder
@MyTypedefaultOptions
defaultOptions
"Api.MyType.decoder"
Uses the given Options
to match the JSON format of derived
FromJSON
and ToJSON
instances.
deriveElmJSONEncoder :: forall a. (HasDatatypeInfo a, HasElmType a, All2 (HasElmEncoder Value) (Code a)) => Options -> Options -> Qualified -> Definition Source #
Automatically create an Elm JSON encoder definition given a Haskell type.
This is suitable for use as a
instance:HasElmEncoderDefinition
Value
instanceHasElmEncoderDefinition
Value
MyType whereelmEncoderDefinition
=deriveElmJSONEncoder
@MyTypedefaultOptions
defaultOptions
"Api.MyType.encoder"
Uses the given Options
to match the JSON format of derived
FromJSON
and ToJSON
instances.
jsonDefinitions :: forall t. (HasElmDefinition t, HasElmEncoderDefinition Value t, HasElmDecoderDefinition Value t) => [Definition] Source #
A shorthand for a list of the type definitions for
is a shorthand for creating a list of its
jsonDefinitions
@MyTypeelmDefinition
,
, and
elmEncoderDefinition
@Value
.elmDecoderDefinition
@Value