ocaml-export-0.13.0: Convert Haskell types in OCaml types

CopyrightPlow Technologies 2017
LicenseBSD3
Maintainermchaver@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

OCaml.BuckleScript.Types

Description

OCaml datatype representation of a Haskell datatype. A recursive tree that can be interpreted to output OCaml code. It is meant to encode a Haskell type into OCaml and make json seraliazers that match the output from Generic aeson instances.

Synopsis

Documentation

data OCamlDatatype Source #

Top level of an OCaml datatype. A data type may be composed of primitives and/or a combination of constructors and primitives. OCamlDatatype is recursive via OCamlConstructor -> ValueConstructor -> OCamlValue -> OCamlPrimitive -> OCamlDatatype.

Constructors

OCamlDatatype HaskellTypeMetaData Text OCamlConstructor

The name of a type and its type constructor

OCamlPrimitive OCamlPrimitive

A primitive value

data OCamlConstructor Source #

OCamlConstructor take values to create a new instances of a type.

Constructors

OCamlValueConstructor ValueConstructor

Sum, record (product with named fields) or product without named fields

OCamlEnumeratorConstructor [EnumeratorConstructor]

Sum of enumerations only. If a sum contains enumerators and at least one constructor with a value then it is an OCamlValueConstructor

OCamlSumOfRecordConstructor Text ValueConstructor

Sum that contains at least one record. This construction is unique to Haskell. It has special Encoding and Decoding rules in order to output a valid OCaml program. i.e. `data A = A {a :: Int} | B {b :: String}`

data ValueConstructor Source #

OCamlConstructor of one RecordConstructor is a record type. OCamlConstructor of one NamedConstructor that has one value is a Haskell newtype. OCamlConstructor of one NamedConstructor is a product without field names. OCamlConstructor of multiple NamedConstructors is a sum type. OCamlConstructor of at least one RecordConstructor and any other amount of ValueConstructors greater than one is a OCamlSumWithRecordConstructor.

Constructors

NamedConstructor Text OCamlValue

Product without named fields

RecordConstructor Text OCamlValue

Product with named fields

MultipleConstructors [ValueConstructor]

Sum type

data OCamlValue Source #

Expected types of a constructor

Constructors

OCamlRef HaskellTypeMetaData Text

The name of a non-primitive data type

OCamlRefApp TypeRep OCamlValue

A type constructor that has at least one type parameter filled

OCamlTypeParameterRef Text

Type parameters like a in `Maybe a`

OCamlEmpty

a place holder for OCaml value. It can represent the end of a list or an Enumerator in a mixed sum

OCamlPrimitiveRef OCamlPrimitive

A primitive OCaml type like int, string, etc.

OCamlField Text OCamlValue

A field name and its type from a record.

Values OCamlValue OCamlValue

Used for multiple types in a NameConstructor or a RecordConstructor.

OCamlRefAppValues OCamlValue OCamlValue

User for multiple types in an OCamlRefApp. These are rendered in a different way from Values.

Instances
Eq OCamlValue Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Show OCamlValue Source # 
Instance details

Defined in OCaml.BuckleScript.Types

class OCamlType a where Source #

Create an OCaml type from a Haskell type. Use the Generic definition when possible. It also expects ToJSON and FromJSON to be derived generically.

Minimal complete definition

Nothing

Methods

toOCamlType :: a -> OCamlDatatype Source #

toOCamlType :: (Generic a, GenericOCamlDatatype (Rep a)) => a -> OCamlDatatype Source #

Instances
OCamlType Bool Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Char Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Double Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Float Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Int Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Int8 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Int16 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Int32 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Int64 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Integer Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Word Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Word8 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Word16 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Word32 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Word64 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType () Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType ByteString Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Text Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType UTCTime Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType Day Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType a => OCamlType [a] Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType a => OCamlType (Maybe a) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

(OCamlType l, OCamlType r) => OCamlType (Either l r) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

(OCamlType a, OCamlType b) => OCamlType (a, b) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Methods

toOCamlType :: (a, b) -> OCamlDatatype Source #

OCamlType a => OCamlType (Proxy a) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

(OCamlType a, OCamlType b, OCamlType c) => OCamlType (a, b, c) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Methods

toOCamlType :: (a, b, c) -> OCamlDatatype Source #

(OCamlType a, OCamlType b, OCamlType c, OCamlType d) => OCamlType (a, b, c, d) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Methods

toOCamlType :: (a, b, c, d) -> OCamlDatatype Source #

(OCamlType a, OCamlType b, OCamlType c, OCamlType d, OCamlType e) => OCamlType (a, b, c, d, e) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Methods

toOCamlType :: (a, b, c, d, e) -> OCamlDatatype Source #

(OCamlType a, OCamlType b, OCamlType c, OCamlType d, OCamlType e, OCamlType f) => OCamlType (a, b, c, d, e, f) Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Methods

toOCamlType :: (a, b, c, d, e, f) -> OCamlDatatype Source #

typeableToOCamlType :: forall a. Typeable a => Proxy a -> OCamlDatatype Source #

for any type that does not use the same serialization as Generic Aeson and has a manually written OCaml definition, should manually derive OCamlType using this function for convenience.

instance OCamlType X where toOCamlType _ = typeableToOCamlType (Proxy :: Proxy X)

newtype TypeParameterRef0 Source #

Used to fill the type parameters of proxy types. `Proxy :: Proxy (Maybe TypeParameterRef0)`, `Proxy :: Proxy Either TypeParameterRef0 TypeParameterRef1`. JSON representation is as an Int to simplify the automated tests.

Constructors

TypeParameterRef0 Int 
Instances
Eq TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Read TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Show TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Generic TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Associated Types

type Rep TypeParameterRef0 :: Type -> Type #

Arbitrary TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToJSON TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

FromJSON TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToADTArbitrary TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef0 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef0 = D1 (MetaData "TypeParameterRef0" "OCaml.BuckleScript.Types" "ocaml-export-0.13.0-FgnypFfzJXvE8go9rtnKhY" True) (C1 (MetaCons "TypeParameterRef0" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

newtype TypeParameterRef1 Source #

Second unique TypeParameterRef.

Constructors

TypeParameterRef1 Int 
Instances
Eq TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Read TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Show TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Generic TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Associated Types

type Rep TypeParameterRef1 :: Type -> Type #

Arbitrary TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToJSON TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

FromJSON TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToADTArbitrary TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef1 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef1 = D1 (MetaData "TypeParameterRef1" "OCaml.BuckleScript.Types" "ocaml-export-0.13.0-FgnypFfzJXvE8go9rtnKhY" True) (C1 (MetaCons "TypeParameterRef1" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

data TypeParameterRef2 Source #

Third unique TypeParameterRef.

Constructors

TypeParameterRef2 Int 
Instances
Eq TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Read TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Show TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Generic TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Associated Types

type Rep TypeParameterRef2 :: Type -> Type #

Arbitrary TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToJSON TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

FromJSON TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToADTArbitrary TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef2 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef2 = D1 (MetaData "TypeParameterRef2" "OCaml.BuckleScript.Types" "ocaml-export-0.13.0-FgnypFfzJXvE8go9rtnKhY" False) (C1 (MetaCons "TypeParameterRef2" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

data TypeParameterRef3 Source #

Fourth unique TypeParameterRef.

Constructors

TypeParameterRef3 Int 
Instances
Eq TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Read TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Show TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Generic TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Associated Types

type Rep TypeParameterRef3 :: Type -> Type #

Arbitrary TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToJSON TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

FromJSON TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToADTArbitrary TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef3 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef3 = D1 (MetaData "TypeParameterRef3" "OCaml.BuckleScript.Types" "ocaml-export-0.13.0-FgnypFfzJXvE8go9rtnKhY" False) (C1 (MetaCons "TypeParameterRef3" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

data TypeParameterRef4 Source #

Fifth unique TypeParameterRef.

Constructors

TypeParameterRef4 Int 
Instances
Eq TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Read TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Show TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Generic TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Associated Types

type Rep TypeParameterRef4 :: Type -> Type #

Arbitrary TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToJSON TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

FromJSON TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToADTArbitrary TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef4 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef4 = D1 (MetaData "TypeParameterRef4" "OCaml.BuckleScript.Types" "ocaml-export-0.13.0-FgnypFfzJXvE8go9rtnKhY" False) (C1 (MetaCons "TypeParameterRef4" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

data TypeParameterRef5 Source #

Sixth unique TypeParameterRef.

Constructors

TypeParameterRef5 Int 
Instances
Eq TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Read TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Show TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Generic TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

Associated Types

type Rep TypeParameterRef5 :: Type -> Type #

Arbitrary TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToJSON TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

FromJSON TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

ToADTArbitrary TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

OCamlType TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef5 Source # 
Instance details

Defined in OCaml.BuckleScript.Types

type Rep TypeParameterRef5 = D1 (MetaData "TypeParameterRef5" "OCaml.BuckleScript.Types" "ocaml-export-0.13.0-FgnypFfzJXvE8go9rtnKhY" False) (C1 (MetaCons "TypeParameterRef5" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

getTypeParameterRefNames :: [OCamlValue] -> [Text] Source #

Convert OCamlValues to the type parameter names of a data type. `Either a0 a1` -> `["a0","a1"]`

getOCamlValues :: ValueConstructor -> [OCamlValue] Source #

getOCamlValues flatten the values from MultipleConstructors into a list and remove ValueConstructor.

getTypeParameters :: OCamlConstructor -> [Text] Source #

get all of the type parameters from an OCamlConstructor.

isTypeParameterRef :: OCamlDatatype -> Bool Source #

Matches all of the TypeParameterRefs (TypeParameterRef0 to TypeParameterRef5). This function is needed to work around the tree structure for special rules for rendering type parameters.

mkModulePrefix :: OCamlTypeMetaData -> OCamlTypeMetaData -> Text Source #

Make OCaml module prefix for a value based on the declaration's and parameter's meta data.

oCamlValueIsFloat :: OCamlValue -> Bool Source #

BuckleScript has a float type that conflicts when you do 'open Aeson.Decode' float must be appended with Decode.

typeRepToHaskellTypeMetaData :: TypeRep -> HaskellTypeMetaData Source #

convert TypeRep to HaskellTypeMetaData

tyConToHaskellTypeMetaData :: TyCon -> HaskellTypeMetaData Source #

convert TyCon to HaskellTypeMetaData