This module contains a data type to represent (plain) types, some basic functionality for types, and an instance for Show.
- type Tps = [Tp]
- data Tp
- intType, stringType, boolType, floatType, charType :: Tp
- (.->.) :: Tp -> Tp -> Tp
- listType :: Tp -> Tp
- ioType :: Tp -> Tp
- tupleType :: Tps -> Tp
- voidType :: Tp
- variablesInType :: Tp -> [Int]
- constantsInType :: Tp -> [String]
- leftSpine :: Tp -> (Tp, Tps)
- functionSpine :: Tp -> (Tps, Tp)
- functionSpineOfLength :: Int -> Tp -> (Tps, Tp)
- arityOfTp :: Tp -> Int
- priorityOfType :: Tp -> Int
- freezeVariablesInType :: Tp -> Tp
- unfreezeVariablesInType :: Tp -> Tp
- isTVar :: Tp -> Bool
- isTCon :: Tp -> Bool
- isTApp :: Tp -> Bool
- isFunctionType :: Tp -> Bool
- isTupleConstructor :: String -> Bool
- isIOType :: Tp -> Bool
- tpParser :: String -> [(Tp, String)]
- class HasTypes a where
Data type definition
A data type to represent monotypes. Note that
Type is already in use
in the Unified Haskell Architecture (UHA) which is used in the Helium compiler
The type variables are numbered.
A type constant is represented by a string.
|TApp Tp Tp|
The application of two Top.Types. Not all types that can be constructed are well-formed.
Constructs a function type from one type to another. This operator is left associative.
A cathesian product of zero or more Top.Types. For instance,
(tupleType ) represents
(tupleType [charType, stringType])
Returns the list of type constants of a type. (no duplicates)
Returns the left spine of a type. For instance, if type
Either Bool [Int], then
leftSpine t is
Returns the right spine of a function type. For instance,
Int -> (Bool -> String), then
Returns the right spine of a function type of a maximal length.
The priority of a type, primarily used for the insertion of parentheses in pretty printing.
All the type variables in a type are frozen by turning them into a type constant. The integer numeral is prefixed with an underscore ('_').