elm-bridge-0.8.4: Derive Elm types and Json code from Haskell types, using aeson's options

Safe Haskell | None
Language | Haskell2010

Elm.TyRep

Description

This module defines how the derived Haskell data types are represented. - It is useful for writing type conversion rules.

Synopsis

- data ETypeDef
  - = ETypeAlias EAlias
  - | ETypePrimAlias EPrimAlias
  - | ETypeSum ESum
- data EType
  - = ETyVar ETVar
  - | ETyCon ETCon
  - | ETyApp EType EType
  - | ETyTuple Int
- newtype ETCon = ETCon {
  - tc_name :: String
  }
- newtype ETVar = ETVar {
  - tv_name :: String
  }
- data ETypeName = ETypeName {
  - et_name :: String
  - et_args :: [ETVar]
  }
- data EPrimAlias = EPrimAlias {
  - epa_name :: ETypeName
  - epa_type :: EType
  }
- data EAlias = EAlias {
  - ea_name :: ETypeName
  - ea_fields :: [(String, EType)]
  - ea_omit_null :: Bool
  - ea_newtype :: Bool
  - ea_unwrap_unary :: Bool
  }
- data SumTypeFields
  - = Anonymous [EType]
  - | Named [(String, EType)]
- isNamed :: SumTypeFields -> Bool
- isEmpty :: SumTypeFields -> Bool
- data SumTypeConstructor = STC {
  - _stcName :: String
  - _stcEncoded :: String
  - _stcFields :: SumTypeFields
  }
- data ESum = ESum {
  - es_name :: ETypeName
  - es_constructors :: [SumTypeConstructor]
  - es_type :: SumEncoding'
  - es_omit_null :: Bool
  - es_unary_strings :: Bool
  }
- unpackTupleType :: EType -> [EType]
- unpackToplevelConstr :: EType -> [EType]
- class IsElmDefinition a where
  - compileElmDef :: Proxy a -> ETypeDef
- newtype SumEncoding' = SumEncoding' SumEncoding
- defSumEncoding :: SumEncoding'
- toElmType :: Typeable a => Proxy a -> EType

# Documentation

data ETypeDef Source #

Type definition, including constructors.

Constructors

ETypeAlias EAlias |
ETypePrimAlias EPrimAlias |
ETypeSum ESum |

#### Instances

Instances details

ElmRenderable ETypeDef Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: ETypeDef -> String Source #
Show ETypeDef Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> ETypeDef -> ShowS Source # show :: ETypeDef -> String Source # showList :: [ETypeDef] -> ShowS Source #
Eq ETypeDef Source # |
Instance details Defined in Elm.TyRep Methods (==) :: ETypeDef -> ETypeDef -> Bool Source # (/=) :: ETypeDef -> ETypeDef -> Bool Source #

data EType Source #

Type construction : type variables, type constructors, tuples and type application.

Constructors

ETyVar ETVar |
ETyCon ETCon |
ETyApp EType EType |
ETyTuple Int |

#### Instances

Instances details

ElmRenderable EType Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: EType -> String Source #
Show EType Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> EType -> ShowS Source # show :: EType -> String Source # showList :: [EType] -> ShowS Source #
Eq EType Source # |
Instance details Defined in Elm.TyRep Methods (==) :: EType -> EType -> Bool Source # (/=) :: EType -> EType -> Bool Source #
Ord EType Source # |
Instance details Defined in Elm.TyRep Methods compare :: EType -> EType -> Ordering Source # (<) :: EType -> EType -> Bool Source # (<=) :: EType -> EType -> Bool Source # (>) :: EType -> EType -> Bool Source # (>=) :: EType -> EType -> Bool Source # max :: EType -> EType -> EType Source # min :: EType -> EType -> EType Source #

newtype ETCon Source #

Type constructor:

    ETCon "Int"

Constructors

ETCon |

Fields

- tc_name :: String

#### Instances

Instances details

ElmRenderable ETCon Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: ETCon -> String Source #
Show ETCon Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> ETCon -> ShowS Source # show :: ETCon -> String Source # showList :: [ETCon] -> ShowS Source #
Eq ETCon Source # |
Instance details Defined in Elm.TyRep Methods (==) :: ETCon -> ETCon -> Bool Source # (/=) :: ETCon -> ETCon -> Bool Source #
Ord ETCon Source # |
Instance details Defined in Elm.TyRep Methods compare :: ETCon -> ETCon -> Ordering Source # (<) :: ETCon -> ETCon -> Bool Source # (<=) :: ETCon -> ETCon -> Bool Source # (>) :: ETCon -> ETCon -> Bool Source # (>=) :: ETCon -> ETCon -> Bool Source # max :: ETCon -> ETCon -> ETCon Source # min :: ETCon -> ETCon -> ETCon Source #

newtype ETVar Source #

Type variable:

    ETVar "a"

Constructors

ETVar |

Fields

- tv_name :: String

#### Instances

Instances details

ElmRenderable ETVar Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: ETVar -> String Source #
Show ETVar Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> ETVar -> ShowS Source # show :: ETVar -> String Source # showList :: [ETVar] -> ShowS Source #
Eq ETVar Source # |
Instance details Defined in Elm.TyRep Methods (==) :: ETVar -> ETVar -> Bool Source # (/=) :: ETVar -> ETVar -> Bool Source #
Ord ETVar Source # |
Instance details Defined in Elm.TyRep Methods compare :: ETVar -> ETVar -> Ordering Source # (<) :: ETVar -> ETVar -> Bool Source # (<=) :: ETVar -> ETVar -> Bool Source # (>) :: ETVar -> ETVar -> Bool Source # (>=) :: ETVar -> ETVar -> Bool Source # max :: ETVar -> ETVar -> ETVar Source # min :: ETVar -> ETVar -> ETVar Source #

data ETypeName Source #

Type name:

    ETypeName "Map" [ETVar "k", ETVar "v"]

Constructors

ETypeName |

Fields

- et_name :: String
- et_args :: [ETVar]

#### Instances

Instances details

ElmRenderable ETypeName Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: ETypeName -> String Source #
Show ETypeName Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> ETypeName -> ShowS Source # show :: ETypeName -> String Source # showList :: [ETypeName] -> ShowS Source #
Eq ETypeName Source # |
Instance details Defined in Elm.TyRep Methods (==) :: ETypeName -> ETypeName -> Bool Source # (/=) :: ETypeName -> ETypeName -> Bool Source #
Ord ETypeName Source # |
Instance details Defined in Elm.TyRep Methods compare :: ETypeName -> ETypeName -> Ordering Source # (<) :: ETypeName -> ETypeName -> Bool Source # (<=) :: ETypeName -> ETypeName -> Bool Source # (>) :: ETypeName -> ETypeName -> Bool Source # (>=) :: ETypeName -> ETypeName -> Bool Source # max :: ETypeName -> ETypeName -> ETypeName Source # min :: ETypeName -> ETypeName -> ETypeName Source #

data EPrimAlias Source #

Constructors

EPrimAlias |

Fields

- epa_name :: ETypeName
- epa_type :: EType

#### Instances

Instances details

ElmRenderable EPrimAlias Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: EPrimAlias -> String Source #
Show EPrimAlias Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> EPrimAlias -> ShowS Source # show :: EPrimAlias -> String Source # showList :: [EPrimAlias] -> ShowS Source #
Eq EPrimAlias Source # |
Instance details Defined in Elm.TyRep Methods (==) :: EPrimAlias -> EPrimAlias -> Bool Source # (/=) :: EPrimAlias -> EPrimAlias -> Bool Source #
Ord EPrimAlias Source # |

Instance details

Defined in Elm.TyRep

Methods

compare :: EPrimAlias -> EPrimAlias -> Ordering Source #

(<) :: EPrimAlias -> EPrimAlias -> Bool Source #

(<=) :: EPrimAlias -> EPrimAlias -> Bool Source #

(>) :: EPrimAlias -> EPrimAlias -> Bool Source #

(>=) :: EPrimAlias -> EPrimAlias -> Bool Source #

max :: EPrimAlias -> EPrimAlias -> EPrimAlias Source #

min :: EPrimAlias -> EPrimAlias -> EPrimAlias Source #

data EAlias Source #

Constructors

EAlias |

Fields

- ea_name :: ETypeName
- ea_fields :: [(String, EType)]
- ea_omit_null :: Bool
- ea_newtype :: Bool
- ea_unwrap_unary :: Bool

#### Instances

Instances details

ElmRenderable EAlias Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: EAlias -> String Source #
Show EAlias Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> EAlias -> ShowS Source # show :: EAlias -> String Source # showList :: [EAlias] -> ShowS Source #
Eq EAlias Source # |
Instance details Defined in Elm.TyRep Methods (==) :: EAlias -> EAlias -> Bool Source # (/=) :: EAlias -> EAlias -> Bool Source #
Ord EAlias Source # |
Instance details Defined in Elm.TyRep Methods compare :: EAlias -> EAlias -> Ordering Source # (<) :: EAlias -> EAlias -> Bool Source # (<=) :: EAlias -> EAlias -> Bool Source # (>) :: EAlias -> EAlias -> Bool Source # (>=) :: EAlias -> EAlias -> Bool Source # max :: EAlias -> EAlias -> EAlias Source # min :: EAlias -> EAlias -> EAlias Source #

data SumTypeFields Source #

Constructors

Anonymous [EType] |
Named [(String, EType)] |

#### Instances

Instances details

Show SumTypeFields Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> SumTypeFields -> ShowS Source # show :: SumTypeFields -> String Source # showList :: [SumTypeFields] -> ShowS Source #
Eq SumTypeFields Source # |
Instance details Defined in Elm.TyRep Methods (==) :: SumTypeFields -> SumTypeFields -> Bool Source # (/=) :: SumTypeFields -> SumTypeFields -> Bool Source #
Ord SumTypeFields Source # |

Instance details

Defined in Elm.TyRep

Methods

compare :: SumTypeFields -> SumTypeFields -> Ordering Source #

(<) :: SumTypeFields -> SumTypeFields -> Bool Source #

(<=) :: SumTypeFields -> SumTypeFields -> Bool Source #

(>) :: SumTypeFields -> SumTypeFields -> Bool Source #

(>=) :: SumTypeFields -> SumTypeFields -> Bool Source #

max :: SumTypeFields -> SumTypeFields -> SumTypeFields Source #

min :: SumTypeFields -> SumTypeFields -> SumTypeFields Source #

isNamed :: SumTypeFields -> Bool Source #

isEmpty :: SumTypeFields -> Bool Source #

data SumTypeConstructor Source #

Constructors

STC |

Fields

- _stcName :: String
- _stcEncoded :: String
- _stcFields :: SumTypeFields

#### Instances

Instances details

Show SumTypeConstructor Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> SumTypeConstructor -> ShowS Source # show :: SumTypeConstructor -> String Source # showList :: [SumTypeConstructor] -> ShowS Source #
Eq SumTypeConstructor Source # |
Instance details Defined in Elm.TyRep Methods (==) :: SumTypeConstructor -> SumTypeConstructor -> Bool Source # (/=) :: SumTypeConstructor -> SumTypeConstructor -> Bool Source #
Ord SumTypeConstructor Source # |

Instance details

Defined in Elm.TyRep

Methods

compare :: SumTypeConstructor -> SumTypeConstructor -> Ordering Source #

(<) :: SumTypeConstructor -> SumTypeConstructor -> Bool Source #

(<=) :: SumTypeConstructor -> SumTypeConstructor -> Bool Source #

(>) :: SumTypeConstructor -> SumTypeConstructor -> Bool Source #

(>=) :: SumTypeConstructor -> SumTypeConstructor -> Bool Source #

max :: SumTypeConstructor -> SumTypeConstructor -> SumTypeConstructor Source #

min :: SumTypeConstructor -> SumTypeConstructor -> SumTypeConstructor Source #

data ESum Source #

Constructors

ESum |

Fields

- es_name :: ETypeName
- es_constructors :: [SumTypeConstructor]
- es_type :: SumEncoding'
- es_omit_null :: Bool
- es_unary_strings :: Bool

#### Instances

Instances details

ElmRenderable ESum Source # |
Instance details Defined in Elm.TyRender Methods renderElm :: ESum -> String Source #
Show ESum Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> ESum -> ShowS Source # show :: ESum -> String Source # showList :: [ESum] -> ShowS Source #
Eq ESum Source # |
Instance details Defined in Elm.TyRep Methods (==) :: ESum -> ESum -> Bool Source # (/=) :: ESum -> ESum -> Bool Source #
Ord ESum Source # |
Instance details Defined in Elm.TyRep Methods compare :: ESum -> ESum -> Ordering Source # (<) :: ESum -> ESum -> Bool Source # (<=) :: ESum -> ESum -> Bool Source # (>) :: ESum -> ESum -> Bool Source # (>=) :: ESum -> ESum -> Bool Source # max :: ESum -> ESum -> ESum Source # min :: ESum -> ESum -> ESum Source #

unpackTupleType :: EType -> [EType] Source #

Transforms tuple types in a list of types. Otherwise returns a singleton list with the original type.

unpackToplevelConstr :: EType -> [EType] Source #

class IsElmDefinition a where Source #

Methods

compileElmDef :: Proxy a -> ETypeDef Source #

newtype SumEncoding' Source #

Constructors

SumEncoding' SumEncoding |

#### Instances

Instances details

Show SumEncoding' Source # |
Instance details Defined in Elm.TyRep Methods showsPrec :: Int -> SumEncoding' -> ShowS Source # show :: SumEncoding' -> String Source # showList :: [SumEncoding'] -> ShowS Source #
Eq SumEncoding' Source # |
Instance details Defined in Elm.TyRep Methods (==) :: SumEncoding' -> SumEncoding' -> Bool Source # (/=) :: SumEncoding' -> SumEncoding' -> Bool Source #
Ord SumEncoding' Source # |

Instance details

Defined in Elm.TyRep

Methods

compare :: SumEncoding' -> SumEncoding' -> Ordering Source #

(<) :: SumEncoding' -> SumEncoding' -> Bool Source #

(<=) :: SumEncoding' -> SumEncoding' -> Bool Source #

(>) :: SumEncoding' -> SumEncoding' -> Bool Source #

(>=) :: SumEncoding' -> SumEncoding' -> Bool Source #

max :: SumEncoding' -> SumEncoding' -> SumEncoding' Source #

min :: SumEncoding' -> SumEncoding' -> SumEncoding' Source #

defSumEncoding :: SumEncoding' Source #

toElmType :: Typeable a => Proxy a -> EType Source #

Get an `elm-bridge` type representation for a Haskell type. This can be used to render the type declaration via `ElmRenderable` or the the JSON serializer/parser names via `jsonSerForType` and `jsonParserForType`.