-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Definition and serialisation instances for Futhark manifests.
--   
--   The Futhark compiler generates JSON manifest files that describe the C
--   API of a compiled program. This package provides definitions for
--   reading and writing such files.
@package futhark-manifest
@version 1.5.0.0

-- | C manifest data structure and serialisation to JSON.
--   
--   A manifest contains machine-readable information about the API of the
--   compiled Futhark program. Specifically which entry points are
--   available, which types are exposed, and what their C names are. This
--   module documentation is not intended as a full description of the
--   Futhark C API - you will need to consult the Futhark User's Guide to
--   understand most of the information here.
--   
--   The type aliases are purely informative and do not actually enforce
--   correct usage. They are present only because most of the information
--   here is ultimately just text.
module Futhark.Manifest

-- | The name of a C function.
type CFuncName = Text

-- | The name of a C type (often of the form "struct foo*").
type CTypeName = Text

-- | The name of a Futhark-level type. This may be an array type (without
--   sizes, just empty brackets), a primitive type, or another string
--   denoting an opaque type. The latter must have a corresponding entry in
--   manifestTypes.
type TypeName = Text

-- | A manifest for a compiled program.
data Manifest
Manifest :: Map Text EntryPoint -> Map TypeName Type -> Text -> Text -> Manifest

-- | A mapping from Futhark entry points to how they are represented in C.
[manifestEntryPoints] :: Manifest -> Map Text EntryPoint

-- | A mapping from Futhark type name to how they are represented at the C
--   level. Should not contain any of the primitive scalar types. For array
--   types, these have empty dimensions, e.g. []i32.
[manifestTypes] :: Manifest -> Map TypeName Type

-- | The compiler backend used to compile the program, e.g. c.
[manifestBackend] :: Manifest -> Text

-- | The version of the compiler used to compile the program.
[manifestVersion] :: Manifest -> Text

-- | Manifest info for an entry point parameter.
data Input
Input :: Text -> TypeName -> Bool -> Input
[inputName] :: Input -> Text
[inputType] :: Input -> TypeName
[inputUnique] :: Input -> Bool

-- | Manifest info for an entry point return value.
data Output
Output :: TypeName -> Bool -> Output
[outputType] :: Output -> TypeName
[outputUnique] :: Output -> Bool

-- | Manifest info for an entry point.
data EntryPoint
EntryPoint :: CFuncName -> [Text] -> [Output] -> [Input] -> EntryPoint
[entryPointCFun] :: EntryPoint -> CFuncName
[entryPointTuningParams] :: EntryPoint -> [Text]
[entryPointOutputs] :: EntryPoint -> [Output]
[entryPointInputs] :: EntryPoint -> [Input]

-- | Manifest info for a non-scalar type. Scalar types are not part of the
--   manifest for a program. Although this representation allows a type to
--   be both a a record and a sum type, this will never actually happen.
data Type

-- | ctype, Futhark elemtype, rank.
TypeArray :: CTypeName -> TypeName -> Int -> ArrayOps -> Type
TypeOpaque :: CTypeName -> OpaqueOps -> Maybe OpaqueExtraOps -> Type

-- | The names of the C functions implementing the operations on some array
--   type.
data ArrayOps
ArrayOps :: CFuncName -> CFuncName -> CFuncName -> CFuncName -> CFuncName -> CFuncName -> CFuncName -> ArrayOps
[arrayFree] :: ArrayOps -> CFuncName
[arrayShape] :: ArrayOps -> CFuncName
[arrayValues] :: ArrayOps -> CFuncName
[arrayNew] :: ArrayOps -> CFuncName
[arrayNewRaw] :: ArrayOps -> CFuncName
[arrayValuesRaw] :: ArrayOps -> CFuncName
[arrayIndex] :: ArrayOps -> CFuncName

-- | Information about a record field. Also used for fields of record
--   arrays; see RecordArrayOps.
data RecordField
RecordField :: Text -> TypeName -> CFuncName -> RecordField

-- | The original name of the field. This may be a name that is not a valid
--   C identifier.
[recordFieldName] :: RecordField -> Text

-- | The type of the field.
[recordFieldType] :: RecordField -> TypeName

-- | The name of the projection function.
[recordFieldProject] :: RecordField -> CFuncName

-- | Some opaque types are records, from which we can extract fields, and
--   also construct them from values for their fields. Beyond that, they
--   support the usual opaque operations. These record facilities can be
--   ignored if you wish, and the types treated as ordinary opaque types.
data RecordOps
RecordOps :: [RecordField] -> CFuncName -> RecordOps

-- | Note that the ordering of fields here is semantically significant - it
--   is also the order that the "new" function expects.
[recordFields] :: RecordOps -> [RecordField]
[recordNew] :: RecordOps -> CFuncName

-- | Information about a variant of a sum type.
data SumVariant
SumVariant :: Text -> [TypeName] -> CFuncName -> CFuncName -> SumVariant

-- | The name of the constructor. This may be a name that is not a valid C
--   identifier.
[sumVariantName] :: SumVariant -> Text

-- | The payload of this variant; also corresponding to the arguments of
--   the constructor and destructor functions.
[sumVariantPayload] :: SumVariant -> [TypeName]
[sumVariantConstruct] :: SumVariant -> CFuncName

-- | Note that despite the name, "destruction" does not entail freeing the
--   sum type value.
[sumVariantDestruct] :: SumVariant -> CFuncName

-- | Some opaque types are sum types, from which we can (try to) extract
--   the payload of a constructor, as well as construct them from payloads.
--   As with records, we can ignore these facilities and simply treat them
--   as completely opaque.
data SumOps
SumOps :: [SumVariant] -> CFuncName -> SumOps
[sumVariants] :: SumOps -> [SumVariant]

-- | This function returns an integer that identifies which variant a value
--   is an instance of. This integer is a valid index in
--   sumVariants.
[sumVariant] :: SumOps -> CFuncName

-- | Some opaque types are arrays of opaque types. These still support some
--   array-like operations, but their types are somewhat different. Note
--   that arrays of primitives are TypeArrays, and arrays of records
--   support RecordArrayOps.
data OpaqueArrayOps
OpaqueArrayOps :: Int -> TypeName -> CFuncName -> CFuncName -> OpaqueArrayOps
[opaqueArrayRank] :: OpaqueArrayOps -> Int
[opaqueArrayElemType] :: OpaqueArrayOps -> TypeName
[opaqueArrayIndex] :: OpaqueArrayOps -> CFuncName
[opaqueArrayShape] :: OpaqueArrayOps -> CFuncName

-- | Some opaque types are arrays of records. The RecordFields here
--   will contain array types, and the projection functions will retrieve
--   arrays.
data RecordArrayOps
RecordArrayOps :: Int -> TypeName -> [RecordField] -> CFuncName -> CFuncName -> CFuncName -> RecordArrayOps
[recordArrayRank] :: RecordArrayOps -> Int
[recordArrayElemType] :: RecordArrayOps -> TypeName
[recordArrayFields] :: RecordArrayOps -> [RecordField]
[recordArrayZip] :: RecordArrayOps -> CFuncName
[recordArrayIndex] :: RecordArrayOps -> CFuncName
[recordArrayShape] :: RecordArrayOps -> CFuncName

-- | Some opaque types have a known structure, which allows additional
--   operations.
data OpaqueExtraOps
OpaqueRecord :: RecordOps -> OpaqueExtraOps
OpaqueSum :: SumOps -> OpaqueExtraOps
OpaqueArray :: OpaqueArrayOps -> OpaqueExtraOps
OpaqueRecordArray :: RecordArrayOps -> OpaqueExtraOps

-- | The names of the C functions implementing the operations on some
--   opaque type.
data OpaqueOps
OpaqueOps :: CFuncName -> CFuncName -> CFuncName -> OpaqueOps
[opaqueFree] :: OpaqueOps -> CFuncName
[opaqueStore] :: OpaqueOps -> CFuncName
[opaqueRestore] :: OpaqueOps -> CFuncName

-- | Serialise a manifest to JSON.
manifestToJSON :: Manifest -> Text

-- | Read a manifest from JSON. Returns Nothing if the text does not
--   describe a Manifest.
manifestFromJSON :: Text -> Maybe Manifest
instance GHC.Show.Show Futhark.Manifest.Input
instance GHC.Classes.Ord Futhark.Manifest.Input
instance GHC.Classes.Eq Futhark.Manifest.Input
instance GHC.Show.Show Futhark.Manifest.Output
instance GHC.Classes.Ord Futhark.Manifest.Output
instance GHC.Classes.Eq Futhark.Manifest.Output
instance GHC.Show.Show Futhark.Manifest.EntryPoint
instance GHC.Classes.Ord Futhark.Manifest.EntryPoint
instance GHC.Classes.Eq Futhark.Manifest.EntryPoint
instance GHC.Show.Show Futhark.Manifest.ArrayOps
instance GHC.Classes.Ord Futhark.Manifest.ArrayOps
instance GHC.Classes.Eq Futhark.Manifest.ArrayOps
instance GHC.Show.Show Futhark.Manifest.RecordField
instance GHC.Classes.Ord Futhark.Manifest.RecordField
instance GHC.Classes.Eq Futhark.Manifest.RecordField
instance GHC.Show.Show Futhark.Manifest.RecordOps
instance GHC.Classes.Ord Futhark.Manifest.RecordOps
instance GHC.Classes.Eq Futhark.Manifest.RecordOps
instance GHC.Show.Show Futhark.Manifest.SumVariant
instance GHC.Classes.Ord Futhark.Manifest.SumVariant
instance GHC.Classes.Eq Futhark.Manifest.SumVariant
instance GHC.Show.Show Futhark.Manifest.SumOps
instance GHC.Classes.Ord Futhark.Manifest.SumOps
instance GHC.Classes.Eq Futhark.Manifest.SumOps
instance GHC.Show.Show Futhark.Manifest.OpaqueArrayOps
instance GHC.Classes.Ord Futhark.Manifest.OpaqueArrayOps
instance GHC.Classes.Eq Futhark.Manifest.OpaqueArrayOps
instance GHC.Show.Show Futhark.Manifest.RecordArrayOps
instance GHC.Classes.Ord Futhark.Manifest.RecordArrayOps
instance GHC.Classes.Eq Futhark.Manifest.RecordArrayOps
instance GHC.Show.Show Futhark.Manifest.OpaqueExtraOps
instance GHC.Classes.Ord Futhark.Manifest.OpaqueExtraOps
instance GHC.Classes.Eq Futhark.Manifest.OpaqueExtraOps
instance GHC.Show.Show Futhark.Manifest.OpaqueOps
instance GHC.Classes.Ord Futhark.Manifest.OpaqueOps
instance GHC.Classes.Eq Futhark.Manifest.OpaqueOps
instance GHC.Show.Show Futhark.Manifest.Type
instance GHC.Classes.Ord Futhark.Manifest.Type
instance GHC.Classes.Eq Futhark.Manifest.Type
instance GHC.Show.Show Futhark.Manifest.Manifest
instance GHC.Classes.Ord Futhark.Manifest.Manifest
instance GHC.Classes.Eq Futhark.Manifest.Manifest
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.Manifest
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.Manifest
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.Type
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.OpaqueOps
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.OpaqueOps
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.RecordArrayOps
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.RecordArrayOps
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.OpaqueArrayOps
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.OpaqueArrayOps
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.SumOps
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.SumOps
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.SumVariant
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.SumVariant
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.RecordOps
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.RecordOps
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.RecordField
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.RecordField
instance Data.Aeson.Types.ToJSON.ToJSON Futhark.Manifest.ArrayOps
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.ArrayOps
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.EntryPoint
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.Output
instance Data.Aeson.Types.FromJSON.FromJSON Futhark.Manifest.Input
