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

Safe Haskell | None
Language | Haskell2010

Elm.Json

Description

This module implements a generator for JSON serialisers and parsers of arbitrary elm types.

It is highly recommended to either only use the functions of Elm.Module, or to use the functions in this module after having modified the `ETypeDef` arguments with functions such as `defaultAlterations`.

The reason is that Elm types might have an equivalent on the Haskell side and should be converted (ie. `Text` -> `String`, `Vector` -> `[]`).

Synopsis

- jsonParserForDef :: ETypeDef -> String
- jsonSerForDef :: ETypeDef -> String
- jsonParserForType :: EType -> String
- jsonSerForType :: EType -> String
- stringSerForSimpleAdt :: ETypeDef -> String
- stringParserForSimpleAdt :: ETypeDef -> String

# Documentation

jsonParserForDef :: ETypeDef -> String Source #

Compile a JSON parser for an Elm type definition

jsonSerForDef :: ETypeDef -> String Source #

Compile a JSON serializer for an Elm type definition

jsonParserForType :: EType -> String Source #

Compile a JSON parser for an Elm type

jsonSerForType :: EType -> String Source #

Compile a JSON serializer for an Elm type.

The `omitNothingFields` option is currently not implemented!

stringSerForSimpleAdt :: ETypeDef -> String Source #

Serialize a type like 'type Color = Red | Green | Blue' in a function like

    stringEncColor : Color -> String
    stringEncColor x =
      case x of
        Red -> "red"
        ...

This is mainly useful for types which are used as part of query parameters and url captures.

stringParserForSimpleAdt :: ETypeDef -> String Source #

Parse a String into a maybe-value for simple ADT types. See `stringSerForSimpleAdt` for motivation