copilot-core-3.4: An intermediate representation for Copilot.
Safe HaskellSafe
LanguageHaskell2010

Copilot.Core.Type

Description

Typing for Core.

All expressions and streams in Core are accompanied by a representation of the types of the underlying expressions used or carried by the streams. This information is needed by the compiler to generate code, since it must initialize variables and equivalent representations for those types in the target languages.

Synopsis

Documentation

data Type :: * -> * where Source #

A Type representing the types of expressions or values handled by Copilot Core.

Note that both arrays and structs use dependently typed features. In the former, the length of the array is part of the type. In the latter, the names of the fields are part of the type.

Constructors

Bool :: Type Bool 
Int8 :: Type Int8 
Int16 :: Type Int16 
Int32 :: Type Int32 
Int64 :: Type Int64 
Word8 :: Type Word8 
Word16 :: Type Word16 
Word32 :: Type Word32 
Word64 :: Type Word64 
Float :: Type Float 
Double :: Type Double 
Array :: forall n t. (KnownNat n, Typed t, Typed (InnerType t), Flatten t (InnerType t)) => Type t -> Type (Array n t) 
Struct :: (Typed a, Struct a) => a -> Type a 

Instances

Instances details
EqualType Type Source # 
Instance details

Defined in Copilot.Core.Type

Methods

(=~=) :: Type a -> Type b -> Maybe (Equal a b) Source #

class (Show a, Typeable a) => Typed a where Source #

A typed expression, from which we can obtain the two type representations used by Copilot: Type and SimpleType.

Minimal complete definition

typeOf

Instances

Instances details
Typed Bool Source # 
Instance details

Defined in Copilot.Core.Type

Typed Double Source # 
Instance details

Defined in Copilot.Core.Type

Typed Float Source # 
Instance details

Defined in Copilot.Core.Type

Typed Int8 Source # 
Instance details

Defined in Copilot.Core.Type

Typed Int16 Source # 
Instance details

Defined in Copilot.Core.Type

Typed Int32 Source # 
Instance details

Defined in Copilot.Core.Type

Typed Int64 Source # 
Instance details

Defined in Copilot.Core.Type

Typed Word8 Source # 
Instance details

Defined in Copilot.Core.Type

Typed Word16 Source # 
Instance details

Defined in Copilot.Core.Type

Typed Word32 Source # 
Instance details

Defined in Copilot.Core.Type

Typed Word64 Source # 
Instance details

Defined in Copilot.Core.Type

(Typeable t, Typed t, KnownNat n, Flatten t (InnerType t), Typed (InnerType t)) => Typed (Array n t) Source # 
Instance details

Defined in Copilot.Core.Type

data UType Source #

A untyped type (no phantom type).

Constructors

forall a.Typeable a => UType 

Fields

Instances

Instances details
Eq UType Source # 
Instance details

Defined in Copilot.Core.Type

Methods

(==) :: UType -> UType -> Bool #

(/=) :: UType -> UType -> Bool #

data SimpleType where Source #

A simple, monomorphic representation of types that facilitates putting variables in heterogeneous lists and environments in spite of their types being different.

Instances

Instances details
Eq SimpleType Source #

Type equality, used to help type inference.

Instance details

Defined in Copilot.Core.Type

tysize :: forall n t. KnownNat n => Type (Array n t) -> Int Source #

Return the total (nested) size of an array from its type

tylength :: forall n t. KnownNat n => Type (Array n t) -> Int Source #

Return the length of an array from its type

data Value a Source #

The field of a struct, together with a representation of its type.

Constructors

forall s t.(Typeable t, KnownSymbol s, Show t) => Value (Type t) (Field s t) 

toValues :: Struct a => a -> [Value a] Source #

Transforms all the struct's fields into a list of values.

data Field (s :: Symbol) t Source #

A field in a struct. The name of the field is a literal at the type level.

Constructors

Field t 

Instances

Instances details
(KnownSymbol s, Show t) => Show (Field s t) Source # 
Instance details

Defined in Copilot.Core.Type

Methods

showsPrec :: Int -> Field s t -> ShowS #

show :: Field s t -> String #

showList :: [Field s t] -> ShowS #

typename :: Struct a => a -> String Source #

Returns the name of struct in the target language.

class Struct a Source #

The value of that is a product or struct, defined as a constructor with several fields.

Minimal complete definition

typename, toValues

fieldname :: forall s t. KnownSymbol s => Field s t -> String Source #

Extract the name of a field.

accessorname :: forall a s t. (Struct a, KnownSymbol s) => (a -> Field s t) -> String Source #

Extract the name of an accessor (a function that returns a field of a struct).

Orphan instances

(Typed t, Struct t) => Show t Source # 
Instance details

Methods

showsPrec :: Int -> t -> ShowS #

show :: t -> String #

showList :: [t] -> ShowS #