Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class HasElmType a where
- elmType :: Type v
- elmDefinition :: Maybe Definition
- class HasElmType a => HasElmDecoder value a where
- class HasElmType a => HasElmEncoder value a where
- newtype Options = Options {
- fieldLabelModifier :: String -> String
- defaultOptions :: Options
- deriveElmTypeDefinition :: forall a. DeriveParameterisedElmTypeDefinition 0 a => Options -> Qualified -> Definition
- class DeriveParameterisedElmTypeDefinition numParams a where
- data Parameter (n :: Nat)
- parameterName :: Int -> Qualified
- deriveElmJSONDecoder :: forall a. DeriveParameterisedElmDecoderDefinition 0 Value a => Options -> Options -> Qualified -> Definition
- class DeriveParameterisedElmDecoderDefinition numParams value a where
- deriveElmJSONEncoder :: forall a. DeriveParameterisedElmEncoderDefinition 0 Value a => Options -> Options -> Qualified -> Definition
- class DeriveParameterisedElmEncoderDefinition numParams value a where
- jsonDefinitions :: forall t. (HasElmEncoder Value t, HasElmDecoder Value t) => [Definition]
Classes
class HasElmType a where Source #
Represents that the corresponding Elm type for the Haskell type a
is
.elmType
@a
elmDefinition :: Maybe Definition Source #
When Just
, this 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
.
When Nothing
, it means that the type is an already existing Elm type
that does not need to be generated.
Instances
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
elmDecoder :: Expression v Source #
default elmDecoder :: Expression v Source #
elmDecoderDefinition :: Maybe Definition Source #
When Just
, this 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
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.
elmEncoder :: Expression v Source #
default elmEncoder :: Expression v Source #
elmEncoderDefinition :: Maybe Definition Source #
When Just
, this 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
Instances
Derivers
Elm code generation options
Options | |
|
Type definitions
deriveElmTypeDefinition :: forall a. DeriveParameterisedElmTypeDefinition 0 a => Options -> Qualified -> Definition Source #
Automatically create an Elm definition given a Haskell type.
This is suitable for use as the elmDefinition
in a HasElmType
instance:
instanceHasElmType
MyType whereelmDefinition
=Just
$deriveElmTypeDefinition
@MyTypedefaultOptions
"Api.MyType.MyType"
class DeriveParameterisedElmTypeDefinition numParams a where Source #
Instances
(KnownNat numParams, HasDatatypeInfo a, All2 (HasElmType :: Type -> Constraint) (Code a)) => DeriveParameterisedElmTypeDefinition (numParams :: Nat) (a :: Type) Source # | |
Defined in Language.Haskell.To.Elm | |
DeriveParameterisedElmTypeDefinition (numParams + 1) (f (Parameter numParams)) => DeriveParameterisedElmTypeDefinition (numParams :: Nat) (f :: Type -> b) Source # | |
Defined in Language.Haskell.To.Elm |
data Parameter (n :: Nat) Source #
Instances
KnownNat n => HasElmEncoder (value :: k) (Parameter n :: Type) Source # | |
Defined in Language.Haskell.To.Elm | |
KnownNat n => HasElmDecoder (value :: k) (Parameter n :: Type) Source # | |
Defined in Language.Haskell.To.Elm | |
KnownNat n => HasElmType (Parameter n :: Type) Source # | |
Defined in Language.Haskell.To.Elm |
parameterName :: Int -> Qualified Source #
JSON decoders
deriveElmJSONDecoder :: forall a. DeriveParameterisedElmDecoderDefinition 0 Value a => Options -> Options -> Qualified -> Definition Source #
Automatically create an Elm JSON decoder definition given a Haskell type.
This is suitable for use as the elmDecoderDefinition
in a
instance:HasElmDecoder
Value
instanceHasElmDecoder
Value
MyType whereelmDecoderDefinition
= Just $deriveElmJSONDecoder
@MyTypedefaultOptions
defaultOptions
"Api.MyType.decoder"
Uses the given Options
to match the JSON format of derived
FromJSON
and ToJSON
instances.
class DeriveParameterisedElmDecoderDefinition numParams value a where Source #
Instances
DeriveParameterisedElmDecoderDefinition (numParams + 1) value (f (Parameter numParams)) => DeriveParameterisedElmDecoderDefinition (numParams :: Nat) (value :: k) (f :: Type -> b) Source # | |
Defined in Language.Haskell.To.Elm | |
(HasElmType a, KnownNat numParams, HasDatatypeInfo a, All2 (HasElmDecoder Value :: Type -> Constraint) (Code a)) => DeriveParameterisedElmDecoderDefinition (numParams :: Nat) Value (a :: Type) Source # | |
Defined in Language.Haskell.To.Elm |
JSON encoders
deriveElmJSONEncoder :: forall a. DeriveParameterisedElmEncoderDefinition 0 Value a => Options -> Options -> Qualified -> Definition Source #
Automatically create an Elm JSON encoder definition given a Haskell type.
This is suitable for use as the elmEncoderDefinition
in a 'HasElmEncoder
instance:Value
instanceHasElmEncoder
Value
MyType whereelmEncoderDefinition
=Just
$deriveElmJSONEncoder
@MyTypedefaultOptions
defaultOptions
"Api.MyType.encoder"
Uses the given Options
to match the JSON format of derived
FromJSON
and ToJSON
instances.
class DeriveParameterisedElmEncoderDefinition numParams value a where Source #
Instances
DeriveParameterisedElmEncoderDefinition (numParams + 1) value (f (Parameter numParams)) => DeriveParameterisedElmEncoderDefinition (numParams :: Nat) (value :: k) (f :: Type -> b) Source # | |
Defined in Language.Haskell.To.Elm | |
(HasElmType a, KnownNat numParams, HasDatatypeInfo a, All2 (HasElmEncoder Value :: Type -> Constraint) (Code a)) => DeriveParameterisedElmEncoderDefinition (numParams :: Nat) Value (a :: Type) Source # | |
Defined in Language.Haskell.To.Elm |
jsonDefinitions :: forall t. (HasElmEncoder Value t, HasElmDecoder 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