-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Convert Haskell types in OCaml types -- -- README.md @package ocaml-export @version 0.2.0.0 -- | 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. module OCaml.BuckleScript.Types -- | 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. data OCamlDatatype -- | The name of a type and its type constructor OCamlDatatype :: HaskellTypeMetaData -> Text -> OCamlConstructor -> OCamlDatatype -- | A primitive value OCamlPrimitive :: OCamlPrimitive -> OCamlDatatype -- | Smallest unit of computation in OCaml. data OCamlPrimitive -- | int OInt :: OCamlPrimitive -- | bool, boolean OBool :: OCamlPrimitive -- | char, it gets interpreted as a string because OCaml char does not -- support UTF-8 OChar :: OCamlPrimitive -- | Js_date.t ODate :: OCamlPrimitive -- | float OFloat :: OCamlPrimitive -- | string OString :: OCamlPrimitive -- | () OUnit :: OCamlPrimitive -- | 'a list, 'a Js_array.t OList :: OCamlDatatype -> OCamlPrimitive -- | 'a option OOption :: OCamlDatatype -> OCamlPrimitive -- | 'l 'r Aeson.Compatibility.Either.t OEither :: OCamlDatatype -> OCamlDatatype -> OCamlPrimitive -- | (*) OTuple2 :: OCamlDatatype -> OCamlDatatype -> OCamlPrimitive -- | (**) OTuple3 :: OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlPrimitive -- | (***) OTuple4 :: OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlPrimitive -- | (****) OTuple5 :: OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlPrimitive -- | (*****) OTuple6 :: OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlDatatype -> OCamlPrimitive -- | OCamlConstructor take values to create a new instances of a type. data OCamlConstructor -- | Sum, record (product with named fields) or product without named -- fields OCamlValueConstructor :: ValueConstructor -> OCamlConstructor -- | Sum of enumerations only. If a sum contains enumerators and at least -- one constructor with a value then it is an OCamlValueConstructor OCamlEnumeratorConstructor :: [EnumeratorConstructor] -> OCamlConstructor -- | Sum that contains at least one record. This construction is unique to -- Haskell. pIt has special Encoding and Decoding rules in order to -- output a valid OCaml program. i.e. `data A = A {a :: Int} | B {b :: -- String}` OCamlSumOfRecordConstructor :: Text -> ValueConstructor -> OCamlConstructor -- | 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. data ValueConstructor -- | Product without named fields NamedConstructor :: Text -> OCamlValue -> ValueConstructor -- | Product with named fields RecordConstructor :: Text -> OCamlValue -> ValueConstructor -- | Sum type MultipleConstructors :: [ValueConstructor] -> ValueConstructor -- | Enumerators have no values, only tags. data EnumeratorConstructor -- | Enumerator and its tag EnumeratorConstructor :: Text -> EnumeratorConstructor -- | Expected types of a constructor data OCamlValue -- | The name of a non-primitive data type OCamlRef :: HaskellTypeMetaData -> Text -> OCamlValue -- | Type parameters like a in `Maybe a` OCamlTypeParameterRef :: Text -> OCamlValue -- | a place holder for OCaml value. It can represent the end of a list or -- an Enumerator in a mixed sum OCamlEmpty :: OCamlValue -- | A primitive OCaml type like int, string, etc. OCamlPrimitiveRef :: OCamlPrimitive -> OCamlValue -- | A field name and its type from a record OCamlField :: Text -> OCamlValue -> OCamlValue -- | Used for multiple types in a sum type Values :: OCamlValue -> OCamlValue -> OCamlValue -- | Create an OCaml type from a Haskell type. Use the Generic definition -- when possible. It also expects ToJSON and FromJSON to be -- derived generically. class OCamlType a toOCamlType :: OCamlType a => a -> OCamlDatatype toOCamlType :: (OCamlType a, Generic a, GenericOCamlDatatype (Rep a)) => a -> OCamlDatatype -- | Store data about the Haskell origin of a type. data HaskellTypeMetaData HaskellTypeMetaData :: Text -> Text -> Text -> HaskellTypeMetaData -- | Store data about the OCaml destination of a type. data OCamlTypeMetaData OCamlTypeMetaData :: Text -> [Text] -> [Text] -> OCamlTypeMetaData typeableToOCamlType :: forall a. Typeable a => Proxy a -> OCamlDatatype -- | 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. data TypeParameterRef0 -- | Second unique TypeParameterRef. data TypeParameterRef1 -- | Third unique TypeParameterRef. data TypeParameterRef2 -- | Fourth unique TypeParameterRef. data TypeParameterRef3 -- | Fifth unique TypeParameterRef. data TypeParameterRef4 -- | Sixth unique TypeParameterRef. data TypeParameterRef5 -- | Convert OCamlValues to the type parameter names of a data type. -- `Either a0 a1` -> `["a0","a1"]` getTypeParameterRefNames :: [OCamlValue] -> [Text] -- | getOCamlValues flatten the values from MultipleConstructors into a -- list and remove ValueConstructor. getOCamlValues :: ValueConstructor -> [OCamlValue] -- | getTypePar getTypeParameters :: OCamlConstructor -> [Text] -- | 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. isTypeParameterRef :: OCamlDatatype -> Bool -- | Make OCaml module prefix for a value based on the declaration's and -- parameter's meta data. mkModulePrefix :: OCamlTypeMetaData -> OCamlTypeMetaData -> Text instance GHC.Generics.Generic OCaml.BuckleScript.Types.TypeParameterRef5 instance GHC.Classes.Eq OCaml.BuckleScript.Types.TypeParameterRef5 instance GHC.Show.Show OCaml.BuckleScript.Types.TypeParameterRef5 instance GHC.Read.Read OCaml.BuckleScript.Types.TypeParameterRef5 instance GHC.Generics.Generic OCaml.BuckleScript.Types.TypeParameterRef4 instance GHC.Classes.Eq OCaml.BuckleScript.Types.TypeParameterRef4 instance GHC.Show.Show OCaml.BuckleScript.Types.TypeParameterRef4 instance GHC.Read.Read OCaml.BuckleScript.Types.TypeParameterRef4 instance GHC.Generics.Generic OCaml.BuckleScript.Types.TypeParameterRef3 instance GHC.Classes.Eq OCaml.BuckleScript.Types.TypeParameterRef3 instance GHC.Show.Show OCaml.BuckleScript.Types.TypeParameterRef3 instance GHC.Read.Read OCaml.BuckleScript.Types.TypeParameterRef3 instance GHC.Generics.Generic OCaml.BuckleScript.Types.TypeParameterRef2 instance GHC.Classes.Eq OCaml.BuckleScript.Types.TypeParameterRef2 instance GHC.Show.Show OCaml.BuckleScript.Types.TypeParameterRef2 instance GHC.Read.Read OCaml.BuckleScript.Types.TypeParameterRef2 instance GHC.Generics.Generic OCaml.BuckleScript.Types.TypeParameterRef1 instance GHC.Classes.Eq OCaml.BuckleScript.Types.TypeParameterRef1 instance GHC.Show.Show OCaml.BuckleScript.Types.TypeParameterRef1 instance GHC.Read.Read OCaml.BuckleScript.Types.TypeParameterRef1 instance GHC.Generics.Generic OCaml.BuckleScript.Types.TypeParameterRef0 instance GHC.Classes.Eq OCaml.BuckleScript.Types.TypeParameterRef0 instance GHC.Show.Show OCaml.BuckleScript.Types.TypeParameterRef0 instance GHC.Read.Read OCaml.BuckleScript.Types.TypeParameterRef0 instance GHC.Classes.Eq OCaml.BuckleScript.Types.ValueConstructor instance GHC.Show.Show OCaml.BuckleScript.Types.ValueConstructor instance GHC.Classes.Eq OCaml.BuckleScript.Types.OCamlConstructor instance GHC.Show.Show OCaml.BuckleScript.Types.OCamlConstructor instance GHC.Classes.Eq OCaml.BuckleScript.Types.OCamlDatatype instance GHC.Show.Show OCaml.BuckleScript.Types.OCamlDatatype instance GHC.Classes.Eq OCaml.BuckleScript.Types.OCamlPrimitive instance GHC.Show.Show OCaml.BuckleScript.Types.OCamlPrimitive instance GHC.Classes.Eq OCaml.BuckleScript.Types.OCamlValue instance GHC.Show.Show OCaml.BuckleScript.Types.OCamlValue instance GHC.Classes.Eq OCaml.BuckleScript.Types.EnumeratorConstructor instance GHC.Show.Show OCaml.BuckleScript.Types.EnumeratorConstructor instance GHC.Classes.Ord OCaml.BuckleScript.Types.OCamlTypeMetaData instance GHC.Classes.Eq OCaml.BuckleScript.Types.OCamlTypeMetaData instance GHC.Show.Show OCaml.BuckleScript.Types.OCamlTypeMetaData instance GHC.Classes.Ord OCaml.BuckleScript.Types.HaskellTypeMetaData instance GHC.Classes.Eq OCaml.BuckleScript.Types.HaskellTypeMetaData instance GHC.Show.Show OCaml.BuckleScript.Types.HaskellTypeMetaData instance Test.QuickCheck.Arbitrary.Arbitrary OCaml.BuckleScript.Types.TypeParameterRef5 instance Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary OCaml.BuckleScript.Types.TypeParameterRef5 instance Data.Aeson.Types.FromJSON.FromJSON OCaml.BuckleScript.Types.TypeParameterRef5 instance Data.Aeson.Types.ToJSON.ToJSON OCaml.BuckleScript.Types.TypeParameterRef5 instance OCaml.BuckleScript.Types.OCamlType OCaml.BuckleScript.Types.TypeParameterRef5 instance Test.QuickCheck.Arbitrary.Arbitrary OCaml.BuckleScript.Types.TypeParameterRef4 instance Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary OCaml.BuckleScript.Types.TypeParameterRef4 instance Data.Aeson.Types.FromJSON.FromJSON OCaml.BuckleScript.Types.TypeParameterRef4 instance Data.Aeson.Types.ToJSON.ToJSON OCaml.BuckleScript.Types.TypeParameterRef4 instance OCaml.BuckleScript.Types.OCamlType OCaml.BuckleScript.Types.TypeParameterRef4 instance Test.QuickCheck.Arbitrary.Arbitrary OCaml.BuckleScript.Types.TypeParameterRef3 instance Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary OCaml.BuckleScript.Types.TypeParameterRef3 instance Data.Aeson.Types.FromJSON.FromJSON OCaml.BuckleScript.Types.TypeParameterRef3 instance Data.Aeson.Types.ToJSON.ToJSON OCaml.BuckleScript.Types.TypeParameterRef3 instance OCaml.BuckleScript.Types.OCamlType OCaml.BuckleScript.Types.TypeParameterRef3 instance Test.QuickCheck.Arbitrary.Arbitrary OCaml.BuckleScript.Types.TypeParameterRef2 instance Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary OCaml.BuckleScript.Types.TypeParameterRef2 instance Data.Aeson.Types.FromJSON.FromJSON OCaml.BuckleScript.Types.TypeParameterRef2 instance Data.Aeson.Types.ToJSON.ToJSON OCaml.BuckleScript.Types.TypeParameterRef2 instance OCaml.BuckleScript.Types.OCamlType OCaml.BuckleScript.Types.TypeParameterRef2 instance Test.QuickCheck.Arbitrary.Arbitrary OCaml.BuckleScript.Types.TypeParameterRef1 instance Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary OCaml.BuckleScript.Types.TypeParameterRef1 instance Data.Aeson.Types.FromJSON.FromJSON OCaml.BuckleScript.Types.TypeParameterRef1 instance Data.Aeson.Types.ToJSON.ToJSON OCaml.BuckleScript.Types.TypeParameterRef1 instance OCaml.BuckleScript.Types.OCamlType OCaml.BuckleScript.Types.TypeParameterRef1 instance Test.QuickCheck.Arbitrary.Arbitrary OCaml.BuckleScript.Types.TypeParameterRef0 instance Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary OCaml.BuckleScript.Types.TypeParameterRef0 instance Data.Aeson.Types.FromJSON.FromJSON OCaml.BuckleScript.Types.TypeParameterRef0 instance Data.Aeson.Types.ToJSON.ToJSON OCaml.BuckleScript.Types.TypeParameterRef0 instance OCaml.BuckleScript.Types.OCamlType OCaml.BuckleScript.Types.TypeParameterRef0 instance (GHC.Generics.Constructor c, OCaml.BuckleScript.Types.GenericOCamlValue f) => OCaml.BuckleScript.Types.GenericValueConstructor (GHC.Generics.C1 c f) instance (GHC.Generics.Selector s, OCaml.BuckleScript.Types.GenericOCamlValue a) => OCaml.BuckleScript.Types.GenericOCamlValue (GHC.Generics.S1 s a) instance (OCaml.BuckleScript.Types.GenericOCamlValue f, OCaml.BuckleScript.Types.GenericOCamlValue g) => OCaml.BuckleScript.Types.GenericOCamlValue (f GHC.Generics.:*: g) instance OCaml.BuckleScript.Types.GenericOCamlValue GHC.Generics.U1 instance OCaml.BuckleScript.Types.OCamlType a => OCaml.BuckleScript.Types.GenericOCamlValue (GHC.Generics.Rec0 a) instance (GHC.TypeLits.KnownSymbol typ, GHC.TypeLits.KnownSymbol package, GHC.TypeLits.KnownSymbol modul, OCaml.BuckleScript.Types.GenericValueConstructor f) => OCaml.BuckleScript.Types.GenericOCamlDatatype (GHC.Generics.M1 GHC.Generics.D ('GHC.Generics.MetaData typ modul package 'GHC.Types.False) f) instance (GHC.TypeLits.KnownSymbol typ, GHC.TypeLits.KnownSymbol package, GHC.TypeLits.KnownSymbol modul, OCaml.BuckleScript.Types.GenericValueConstructor f) => OCaml.BuckleScript.Types.GenericOCamlDatatype (GHC.Generics.M1 GHC.Generics.D ('GHC.Generics.MetaData typ modul package 'GHC.Types.True) f) instance (OCaml.BuckleScript.Types.GenericValueConstructor f, OCaml.BuckleScript.Types.GenericValueConstructor g) => OCaml.BuckleScript.Types.GenericValueConstructor (f GHC.Generics.:+: g) instance OCaml.BuckleScript.Types.OCamlType a => OCaml.BuckleScript.Types.OCamlType [a] instance OCaml.BuckleScript.Types.OCamlType a => OCaml.BuckleScript.Types.OCamlType (GHC.Base.Maybe a) instance (OCaml.BuckleScript.Types.OCamlType l, OCaml.BuckleScript.Types.OCamlType r) => OCaml.BuckleScript.Types.OCamlType (Data.Either.Either l r) instance OCaml.BuckleScript.Types.OCamlType () instance OCaml.BuckleScript.Types.OCamlType Data.Text.Internal.Text instance OCaml.BuckleScript.Types.OCamlType Data.Time.Calendar.Days.Day instance OCaml.BuckleScript.Types.OCamlType Data.Time.Clock.Internal.UTCTime.UTCTime instance OCaml.BuckleScript.Types.OCamlType GHC.Types.Float instance OCaml.BuckleScript.Types.OCamlType GHC.Types.Double instance OCaml.BuckleScript.Types.OCamlType GHC.Int.Int8 instance OCaml.BuckleScript.Types.OCamlType GHC.Int.Int16 instance OCaml.BuckleScript.Types.OCamlType GHC.Int.Int32 instance OCaml.BuckleScript.Types.OCamlType GHC.Int.Int64 instance OCaml.BuckleScript.Types.OCamlType GHC.Types.Word instance OCaml.BuckleScript.Types.OCamlType GHC.Word.Word8 instance OCaml.BuckleScript.Types.OCamlType GHC.Word.Word16 instance OCaml.BuckleScript.Types.OCamlType GHC.Word.Word32 instance OCaml.BuckleScript.Types.OCamlType GHC.Word.Word64 instance OCaml.BuckleScript.Types.OCamlType GHC.Types.Int instance OCaml.BuckleScript.Types.OCamlType GHC.Integer.Type.Integer instance OCaml.BuckleScript.Types.OCamlType GHC.Types.Char instance OCaml.BuckleScript.Types.OCamlType GHC.Types.Bool instance (OCaml.BuckleScript.Types.OCamlType a, OCaml.BuckleScript.Types.OCamlType b) => OCaml.BuckleScript.Types.OCamlType (a, b) instance (OCaml.BuckleScript.Types.OCamlType a, OCaml.BuckleScript.Types.OCamlType b, OCaml.BuckleScript.Types.OCamlType c) => OCaml.BuckleScript.Types.OCamlType (a, b, c) instance (OCaml.BuckleScript.Types.OCamlType a, OCaml.BuckleScript.Types.OCamlType b, OCaml.BuckleScript.Types.OCamlType c, OCaml.BuckleScript.Types.OCamlType d) => OCaml.BuckleScript.Types.OCamlType (a, b, c, d) instance (OCaml.BuckleScript.Types.OCamlType a, OCaml.BuckleScript.Types.OCamlType b, OCaml.BuckleScript.Types.OCamlType c, OCaml.BuckleScript.Types.OCamlType d, OCaml.BuckleScript.Types.OCamlType e) => OCaml.BuckleScript.Types.OCamlType (a, b, c, d, e) instance (OCaml.BuckleScript.Types.OCamlType a, OCaml.BuckleScript.Types.OCamlType b, OCaml.BuckleScript.Types.OCamlType c, OCaml.BuckleScript.Types.OCamlType d, OCaml.BuckleScript.Types.OCamlType e, OCaml.BuckleScript.Types.OCamlType f) => OCaml.BuckleScript.Types.OCamlType (a, b, c, d, e, f) instance OCaml.BuckleScript.Types.OCamlType a => OCaml.BuckleScript.Types.OCamlType (Data.Proxy.Proxy a) module OCaml.Internal.Common -- | For URLs and POSIX systems. (>) :: Text -> Text -> Text infix 5 > data Options Options :: Bool -> Options -> Map HaskellTypeMetaData OCamlTypeMetaData -> Options [includeOCamlInterface] :: Options -> Bool [aesonOptions] :: Options -> Options [dependencies] :: Options -> Map HaskellTypeMetaData OCamlTypeMetaData defaultOptions :: Options data TypeMetaData TypeMetaData :: Maybe OCamlTypeMetaData -> Options -> TypeMetaData [topLevelOCamlTypeMetaData] :: TypeMetaData -> Maybe OCamlTypeMetaData [userOptions] :: TypeMetaData -> Options cr :: Format r r mintercalate :: Monoid m => m -> [m] -> m msuffix :: Monoid m => m -> [m] -> m mconcatWith :: Monoid m => m -> m -> [m] -> m mintercalatefinish :: Monoid m => m -> m -> [m] -> m pprinter :: Doc -> Text stext :: Text -> Doc spaceparens :: Doc -> Doc -- | Parentheses of which the right parenthesis exists on a new line newlineparens :: Doc -> Doc -- | An empty line, regardless of current indentation emptyline :: Doc -- | Like $$, but with an empty line in between (<$+$>) :: Doc -> Doc -> Doc linesBetween :: [Doc] -> Doc squarebracks :: Doc -> Doc arraybrackets :: Doc -> Doc pair :: Doc -> Doc -> Doc lowercaseFirst :: String -> String uppercaseFirst :: String -> String textLowercaseFirst :: Text -> Text textUppercaseFirst :: Text -> Text mkDocList :: [Doc] -> Doc foldMod :: [Text] -> Text module OCaml.BuckleScript.Spec mkSampleServerAndGoldenSpec :: OCamlDatatype -> Maybe Int -> [Text] -> Text -> Text -> Doc toOCamlSpec :: OCamlType a => a -> [Text] -> Text -> Text -> Text -- | OCamlTypeInFile do not require an instance of OCamlType since they are -- hand written OCaml files for Haskell types. Use typeable to get the -- type name. typeInFileToOCamlSpec :: OCamlType a => a -> Int -> [Text] -> Text -> Text -> Text -- | For a Haskell type with an instance of OCamlType, output the OCaml -- type declaration. module OCaml.BuckleScript.Record -- | Convert a 'Proxy a' into OCaml type source code. toOCamlTypeSourceWith :: forall a. OCamlType a => Options -> a -> Text instance OCaml.BuckleScript.Record.HasType OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Record.HasTypeRef OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Record.HasType OCaml.BuckleScript.Types.OCamlValue instance OCaml.BuckleScript.Record.HasRecordType OCaml.BuckleScript.Types.OCamlValue instance OCaml.BuckleScript.Record.HasTypeRef OCaml.BuckleScript.Types.OCamlPrimitive instance OCaml.BuckleScript.Record.HasType OCaml.BuckleScript.Types.ValueConstructor instance OCaml.BuckleScript.Record.HasType OCaml.BuckleScript.Types.OCamlConstructor instance OCaml.BuckleScript.Record.HasType OCaml.BuckleScript.Types.EnumeratorConstructor -- | For a Haskell type with an instance of OCamlType, output an OCaml type -- to JSON (aeson) encoder. module OCaml.BuckleScript.Encode -- | Convert a 'Proxy a' into OCaml type to JSON function source code -- without an interface file '.mli'. toOCamlEncoderSourceWith :: forall a. OCamlType a => Options -> a -> Text -- | Convert a 'Proxy a' into OCaml type to JSON function source code which -- expects an interface file '.ml'. toOCamlEncoderInterfaceWith :: forall a. OCamlType a => Options -> a -> Text instance OCaml.BuckleScript.Encode.HasEncoderInterface OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Encode.HasEncoder OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Encode.HasEncoderRef OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Encode.HasEncoder OCaml.BuckleScript.Types.OCamlValue instance OCaml.BuckleScript.Encode.HasEncoderRef OCaml.BuckleScript.Types.OCamlPrimitive instance OCaml.BuckleScript.Encode.HasEncoder OCaml.BuckleScript.Types.OCamlConstructor module OCaml.BuckleScript.Decode -- | Convert a 'Proxy a' into OCaml type to decode JSON function source -- code without an interface file '.mli'. toOCamlDecoderSourceWith :: forall a. OCamlType a => Options -> a -> Text -- | Convert a 'Proxy a' into OCaml type to decode JSON function source -- code with an interface file '.mli'. toOCamlDecoderInterfaceWith :: forall a. OCamlType a => Options -> a -> Text instance OCaml.BuckleScript.Decode.HasDecoderInterface OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Decode.HasDecoder OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Decode.HasDecoderRef OCaml.BuckleScript.Types.OCamlDatatype instance OCaml.BuckleScript.Decode.HasDecoder OCaml.BuckleScript.Types.OCamlValue instance OCaml.BuckleScript.Decode.HasDecoderRef OCaml.BuckleScript.Types.OCamlPrimitive instance OCaml.BuckleScript.Decode.HasDecoder OCaml.BuckleScript.Types.OCamlConstructor instance OCaml.BuckleScript.Decode.HasDecoder OCaml.BuckleScript.Types.EnumeratorConstructor module OCaml.BuckleScript.Internal.Module -- | An OCamlModule as a Haskell type. File level modules is -- relative to a root directory prvoiided in the mkPackage -- function. data OCamlModule (modules :: [Symbol]) -- | Symobl will be expaneded to "module SymbolName = struct ... end". data OCamlSubModule (subModules :: Symbol) -- | A handwritten OCaml type, encoder and decoder from a file. data OCamlTypeInFile a (filePath :: Symbol) -- | Store OCamlFileInType data. data EmbeddedOCamlFiles EmbeddedOCamlFiles :: ByteString -> Maybe ByteString -> Maybe ByteString -> EmbeddedOCamlFiles [eocDeclaration] :: EmbeddedOCamlFiles -> ByteString [eocInterface] :: EmbeddedOCamlFiles -> Maybe ByteString [eocSpec] :: EmbeddedOCamlFiles -> Maybe ByteString -- | Convert a Haskell type into OCaml source code. class HasOCamlType api mkType :: HasOCamlType api => Proxy api -> Options -> Bool -> Map String EmbeddedOCamlFiles -> [Text] mkInterface :: HasOCamlType api => Proxy api -> Options -> Map String EmbeddedOCamlFiles -> [Text] mkSpec :: HasOCamlType api => Proxy api -> Options -> [Text] -> Text -> Text -> Map String EmbeddedOCamlFiles -> [Text] -- | Use Template Haskell to load OCaml files for an OCaml Module at -- compile time. '$(mkFile (Proxy :: Proxy Package))'. class HasEmbeddedFile api mkFiles :: HasEmbeddedFile api => Bool -> Bool -> Proxy api -> Q Exp instance forall k (api :: k). OCaml.BuckleScript.Internal.Module.HasEmbeddedFile' api => OCaml.BuckleScript.Internal.Module.HasEmbeddedFile api instance forall k1 k (a :: k) (b :: k1). (OCaml.BuckleScript.Internal.Module.HasEmbeddedFile' a, OCaml.BuckleScript.Internal.Module.HasEmbeddedFile' b) => OCaml.BuckleScript.Internal.Module.HasEmbeddedFile' (a Servant.API.Sub.:> b) instance forall k (a :: k) (b :: GHC.Types.Symbol). (Data.Typeable.Internal.Typeable a, GHC.TypeLits.KnownSymbol b) => OCaml.BuckleScript.Internal.Module.HasEmbeddedFile' (OCaml.BuckleScript.Internal.Module.OCamlTypeInFile a b) instance forall k (a :: k). OCaml.BuckleScript.Internal.Module.HasEmbeddedFile' a instance (OCaml.BuckleScript.Internal.Module.HasOCamlTypeFlag a ~ flag, OCaml.BuckleScript.Internal.Module.HasOCamlType' flag a) => OCaml.BuckleScript.Internal.Module.HasOCamlType a instance forall k1 (subModule :: GHC.Types.Symbol) (b :: k1). (GHC.TypeLits.KnownSymbol subModule, OCaml.BuckleScript.Internal.Module.HasOCamlType b) => OCaml.BuckleScript.Internal.Module.HasOCamlType' 4 (OCaml.BuckleScript.Internal.Module.OCamlSubModule subModule Servant.API.Sub.:> b) instance forall k1 k (a :: k) (b :: k1). (OCaml.BuckleScript.Internal.Module.HasOCamlType a, OCaml.BuckleScript.Internal.Module.HasOCamlType b) => OCaml.BuckleScript.Internal.Module.HasOCamlType' 3 (a Servant.API.Sub.:> b) instance (OCaml.BuckleScript.Types.OCamlType a, Data.Typeable.Internal.Typeable a) => OCaml.BuckleScript.Internal.Module.HasOCamlType' 2 (OCaml.BuckleScript.Internal.Module.OCamlTypeInFile a b) instance OCaml.BuckleScript.Types.OCamlType a => OCaml.BuckleScript.Internal.Module.HasOCamlType' 1 a module OCaml.BuckleScript.Internal.Package data OCamlPackage (packageName :: Symbol) (packageDependencies :: [*]) type NoDependency = '[] -- | Options for creating an OCaml package based on Haskell types. data PackageOptions PackageOptions :: FilePath -> FilePath -> Map String EmbeddedOCamlFiles -> Bool -> Maybe SpecOptions -> PackageOptions -- | root directory where all relatives directories will be placed. [packageRootDir] :: PackageOptions -> FilePath -- | location to place ml and mli files relative to packageRootDir. [packageSrcDir] :: PackageOptions -> FilePath [packageEmbeddedFiles] :: PackageOptions -> Map String EmbeddedOCamlFiles -- | create an mli file if True. [createInterfaceFile] :: PackageOptions -> Bool -- | produce OCaml spec file if Just. [mSpecOptions] :: PackageOptions -> Maybe SpecOptions -- | Default PackageOptions. defaultPackageOptions :: PackageOptions -- | Details for OCaml spec. data SpecOptions SpecOptions :: FilePath -> FilePath -> String -> SpecOptions -- | Directory in which to store the OCaml spec, relative to -- packageRootDir. [specDir] :: SpecOptions -> FilePath -- | Location of golden JSON files produced by Haskell, relative to -- packageRootDir. [goldenDir] :: SpecOptions -> FilePath -- | The URL of the automated Servant spec server to run OCaml specs -- against. [servantURL] :: SpecOptions -> String -- | Default SpecOptions. defaultSpecOptions :: SpecOptions -- | Iterate over a list of OCamlModule types that are concated with -- '(:|)', to create a package. class HasOCamlPackage a mkPackage :: HasOCamlPackage a => Proxy a -> PackageOptions -> IO () -- | Depending on PackageOptions settings, mkModule can - -- make a declaration file containing encoders and decoders - make an -- OCaml interface file - make a Spec file that tests the encoders and -- decoders against a golden file and a servant server class HasOCamlModule a mkModule :: HasOCamlModule a => Proxy a -> PackageOptions -> Map HaskellTypeMetaData OCamlTypeMetaData -> IO () -- | Produce type meta data for an OCamlPackage and its dependencies class HasOCamlTypeMetaData a mkOCamlTypeMetaData :: HasOCamlTypeMetaData a => Proxy a -> Map HaskellTypeMetaData OCamlTypeMetaData instance (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaDataFlag a ~ flag, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData'' flag a) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData' a instance forall k1 (subModule :: GHC.Types.Symbol) (b :: k1). (GHC.TypeLits.KnownSymbol subModule, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData' b) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData'' 4 (OCaml.BuckleScript.Internal.Module.OCamlSubModule subModule Servant.API.Sub.:> b) instance forall k1 k (a :: k) (b :: k1). (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData' a, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData' b) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData'' 3 (a Servant.API.Sub.:> b) instance forall k (a :: k) (b :: GHC.Types.Symbol). Data.Typeable.Internal.Typeable a => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData'' 2 (OCaml.BuckleScript.Internal.Module.OCamlTypeInFile a b) instance forall k (a :: k). Data.Typeable.Internal.Typeable a => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData'' 1 a instance forall k1 (modules :: [GHC.Types.Symbol]) (api :: k1). (GHC.TypeLits.List.KnownSymbols modules, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData' api) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData (OCaml.BuckleScript.Internal.Module.OCamlModule modules Servant.API.Sub.:> api) instance forall k1 (deps :: [*]) (a :: k1) (packageName :: GHC.Types.Symbol). (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData deps, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData a, OCaml.BuckleScript.Internal.Package.HasOCamlPackage' a) => OCaml.BuckleScript.Internal.Package.HasOCamlPackage (OCaml.BuckleScript.Internal.Package.OCamlPackage packageName deps Servant.API.Sub.:> a) instance forall k (a :: k). (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData a, OCaml.BuckleScript.Internal.Package.HasOCamlPackage' a) => OCaml.BuckleScript.Internal.Package.HasOCamlPackage a instance (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData (OCaml.BuckleScript.Internal.Package.OCamlPackage packageName deps), OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData rest) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData (OCaml.BuckleScript.Internal.Package.OCamlPackage packageName deps Servant.API.Alternative.:<|> rest) instance forall k1 (deps :: [*]) (modules :: k1) (packageName :: GHC.Types.Symbol). (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData deps, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData modules) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData (OCaml.BuckleScript.Internal.Package.OCamlPackage packageName deps Servant.API.Sub.:> modules) instance forall a (modul :: a) (rst :: [a]). (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData modul, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData rst) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData (modul : rst) instance (OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData modul, OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData rst) => OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData (modul Servant.API.Alternative.:<|> rst) instance OCaml.BuckleScript.Internal.Package.HasOCamlTypeMetaData '[] instance forall k1 (modules :: [GHC.Types.Symbol]) (api :: k1). (GHC.TypeLits.List.KnownSymbols modules, OCaml.BuckleScript.Internal.Package.HasOCamlModule' api) => OCaml.BuckleScript.Internal.Package.HasOCamlModule (OCaml.BuckleScript.Internal.Module.OCamlModule modules Servant.API.Sub.:> api) instance forall k (api :: k). OCaml.BuckleScript.Internal.Module.HasOCamlType api => OCaml.BuckleScript.Internal.Package.HasOCamlModule' api instance forall k (a :: k). OCaml.BuckleScript.Internal.Package.HasOCamlModule a => OCaml.BuckleScript.Internal.Package.HasOCamlPackage' a instance (OCaml.BuckleScript.Internal.Package.HasOCamlPackage' modul, OCaml.BuckleScript.Internal.Package.HasOCamlPackage' rest) => OCaml.BuckleScript.Internal.Package.HasOCamlPackage' (modul Servant.API.Alternative.:<|> rest) module OCaml.BuckleScript.Internal.Spec mkOCamlSpecServer :: forall ocamlPackage. (OCamlPackageTypeCount ocamlPackage) => String -> Proxy ocamlPackage -> Q [Dec] -- | Convert an OCamlPackage into a servant API. mkGoldenFiles :: HasMkGoldenFiles a => Proxy a -> Int -> FilePath -> IO () -- | A servant route for a testing an OCaml type's encoder and decoder type OCamlSpecAPI (modules :: [Symbol]) (subModules :: [Symbol]) typ = ConcatSymbols (Insert (TypeName typ) (Append modules subModules)) (ReqBody '[JSON] [typ] :> Post '[JSON] [typ]) class OCamlPackageTypeCount modules ocamlPackageTypeCount :: OCamlPackageTypeCount modules => Proxy modules -> [Int] class OCamlModuleTypeCount api ocamlModuleTypeCount :: OCamlModuleTypeCount api => Proxy api -> Int instance (OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCountFlag a ~ flag, OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCount' flag a) => OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCount a instance forall k1 (b :: k1) (a :: GHC.Types.Symbol) (deps :: [*]). OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCount b => OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCount' 'GHC.Types.True (OCaml.BuckleScript.Internal.Package.OCamlPackage a deps Servant.API.Sub.:> b) instance (OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount a, OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCount b) => OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCount' 'GHC.Types.True (a Servant.API.Alternative.:<|> b) instance forall k (a :: k). OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount a => OCaml.BuckleScript.Internal.Spec.OCamlPackageTypeCount' 'GHC.Types.False a instance (OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCountFlag a ~ flag, OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount' flag a) => OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount a instance forall k1 k (a :: k) (b :: k1). (OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount a, OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount b) => OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount' 'GHC.Types.True (a Servant.API.Sub.:> b) instance OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount' 'GHC.Types.True (OCaml.BuckleScript.Internal.Module.OCamlModule modules) instance OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount' 'GHC.Types.True (OCaml.BuckleScript.Internal.Module.OCamlSubModule subModules) instance forall k (a :: k). OCaml.BuckleScript.Internal.Spec.OCamlModuleTypeCount' 'GHC.Types.False a instance (OCaml.BuckleScript.Internal.Spec.HasMkGoldenFilesFlag a ~ flag, OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' flag a) => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles a instance forall k1 (a :: k1) (packageName :: GHC.Types.Symbol) (deps :: [*]). OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles a => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' 7 (OCaml.BuckleScript.Internal.Package.OCamlPackage packageName deps Servant.API.Sub.:> a) instance forall k1 (a :: k1) b (modules :: [GHC.Types.Symbol]). (OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles a, OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles b) => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' 6 ((OCaml.BuckleScript.Internal.Module.OCamlModule modules Servant.API.Sub.:> a) Servant.API.Alternative.:<|> b) instance forall k1 (a :: k1) (modules :: [GHC.Types.Symbol]). OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles a => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' 5 (OCaml.BuckleScript.Internal.Module.OCamlModule modules Servant.API.Sub.:> a) instance forall k1 (a :: k1) (subModule :: GHC.Types.Symbol). OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles a => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' 4 (OCaml.BuckleScript.Internal.Module.OCamlSubModule subModule Servant.API.Sub.:> a) instance (Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary a, Data.Aeson.Types.ToJSON.ToJSON a) => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' 3 (OCaml.BuckleScript.Internal.Module.OCamlTypeInFile a b) instance forall k1 k (a :: k) (b :: k1). (OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles a, OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles b) => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' 2 (a Servant.API.Sub.:> b) instance (Test.QuickCheck.Arbitrary.ADT.ToADTArbitrary a, Data.Aeson.Types.ToJSON.ToJSON a) => OCaml.BuckleScript.Internal.Spec.HasMkGoldenFiles' 1 a module OCaml.Export data OCamlPackage (packageName :: Symbol) (packageDependencies :: [*]) type NoDependency = '[] -- | An OCamlModule as a Haskell type. File level modules is -- relative to a root directory prvoiided in the mkPackage -- function. data OCamlModule (modules :: [Symbol]) -- | Symobl will be expaneded to "module SymbolName = struct ... end". data OCamlSubModule (subModules :: Symbol) -- | A handwritten OCaml type, encoder and decoder from a file. data OCamlTypeInFile a (filePath :: Symbol) -- | Options for creating an OCaml package based on Haskell types. data PackageOptions PackageOptions :: FilePath -> FilePath -> Map String EmbeddedOCamlFiles -> Bool -> Maybe SpecOptions -> PackageOptions -- | root directory where all relatives directories will be placed. [packageRootDir] :: PackageOptions -> FilePath -- | location to place ml and mli files relative to packageRootDir. [packageSrcDir] :: PackageOptions -> FilePath [packageEmbeddedFiles] :: PackageOptions -> Map String EmbeddedOCamlFiles -- | create an mli file if True. [createInterfaceFile] :: PackageOptions -> Bool -- | produce OCaml spec file if Just. [mSpecOptions] :: PackageOptions -> Maybe SpecOptions -- | Default PackageOptions. defaultPackageOptions :: PackageOptions -- | Details for OCaml spec. data SpecOptions SpecOptions :: FilePath -> FilePath -> String -> SpecOptions -- | Directory in which to store the OCaml spec, relative to -- packageRootDir. [specDir] :: SpecOptions -> FilePath -- | Location of golden JSON files produced by Haskell, relative to -- packageRootDir. [goldenDir] :: SpecOptions -> FilePath -- | The URL of the automated Servant spec server to run OCaml specs -- against. [servantURL] :: SpecOptions -> String -- | Default SpecOptions. defaultSpecOptions :: SpecOptions -- | Store OCamlFileInType data. data EmbeddedOCamlFiles EmbeddedOCamlFiles :: ByteString -> Maybe ByteString -> Maybe ByteString -> EmbeddedOCamlFiles [eocDeclaration] :: EmbeddedOCamlFiles -> ByteString [eocInterface] :: EmbeddedOCamlFiles -> Maybe ByteString [eocSpec] :: EmbeddedOCamlFiles -> Maybe ByteString mkPackage :: HasOCamlPackage a => Proxy a -> PackageOptions -> IO () mkFiles :: HasEmbeddedFile api => Bool -> Bool -> Proxy api -> Q Exp mkOCamlTypeMetaData :: HasOCamlTypeMetaData a => Proxy a -> Map HaskellTypeMetaData OCamlTypeMetaData -- | Create an OCaml type from a Haskell type. Use the Generic definition -- when possible. It also expects ToJSON and FromJSON to be -- derived generically. class OCamlType a toOCamlType :: OCamlType a => a -> OCamlDatatype toOCamlType :: (OCamlType a, Generic a, GenericOCamlDatatype (Rep a)) => a -> OCamlDatatype typeableToOCamlType :: forall a. Typeable a => Proxy a -> OCamlDatatype -- | 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. data TypeParameterRef0 -- | Second unique TypeParameterRef. data TypeParameterRef1 -- | Third unique TypeParameterRef. data TypeParameterRef2 -- | Fourth unique TypeParameterRef. data TypeParameterRef3 -- | Fifth unique TypeParameterRef. data TypeParameterRef4 -- | Sixth unique TypeParameterRef. data TypeParameterRef5 mkOCamlSpecServer :: forall ocamlPackage. (OCamlPackageTypeCount ocamlPackage) => String -> Proxy ocamlPackage -> Q [Dec] -- | Convert an OCamlPackage into a servant API. mkGoldenFiles :: HasMkGoldenFiles a => Proxy a -> Int -> FilePath -> IO () -- | A concrete, poly-kinded proxy type data Proxy k (t :: k) :: forall k. () => k -> * Proxy :: Proxy k -- | The contained API (second argument) can be found under ("/" ++ -- path) (path being the first argument). -- -- Example: -- --
-- >>> -- GET /hello/world -- -- >>> -- returning a JSON encoded World value -- -- >>> type MyApi = "hello" :> "world" :> Get '[JSON] World --data (:>) k k1 (path :: k) (a :: k1) :: forall k k1. () => k -> k1 -> * -- | Union of two APIs, first takes precedence in case of overlap. -- -- Example: -- --
-- >>> :{
-- type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
-- :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] () -- POST /books
-- :}
--
data (:<|>) a b :: * -> * -> *
(:<|>) :: a -> b -> (:<|>) a b
-- | The WAI application.
--
-- Note that, since WAI 3.0, this type is structured in continuation
-- passing style to allow for proper safe resource handling. This was
-- handled in the past via other means (e.g., ResourceT). As a
-- demonstration:
--
-- -- app :: Application -- app req respond = bracket_ -- (putStrLn "Allocating scarce resource") -- (putStrLn "Cleaning up") -- (respond $ responseLBS status200 [] "Hello World") --type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived type Server k (api :: k) = ServerT k api Handler -- | serve allows you to implement an API and produce a wai -- Application. -- -- Example: -- --
-- type MyApi = "books" :> Get '[JSON] [Book] -- GET /books -- :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books -- -- server :: Server MyApi -- server = listAllBooks :<|> postBook -- where listAllBooks = ... -- postBook book = ... -- -- myApi :: Proxy MyApi -- myApi = Proxy -- -- app :: Application -- app = serve myApi server -- -- main :: IO () -- main = Network.Wai.Handler.Warp.run 8080 app --serve :: HasServer * api [] * => Proxy * api -> Server * api -> Application