WashNGo-2.12.0.1: WASH is a family of EDSLs for programming Web applications in Haskell.Source codeContentsIndex
WASH.CGI.Types
Description

The Types module aims at providing a representation for (first-order) monomorphic Haskell types. Two type representations are equal if and only if the represented types have identical definitions. Thus a type representation consists of a type term and the smallest list of all (data or newtype) definitions needed either in the type term or in another definition. The list of definitions is sorted to make representations unique.

The main use of type representations is to provide a type index for storing Haskell values externally and for reading them back into a running program without sacrificing type safety. Just reading them back with the Read class is not sufficient because

  • Read does not distinguish between Int and Integer, Float and Doubley
  • Read cannot avoid accidental matches of constructor names

Meanwhile, the Data.Typeable class of GHC provides an encoding with similar goals.

Synopsis
data TySpec = TS TyRep [TyDecl]
data TyRep
= TRBase String
| TRVar String
| TRTuple [TyRep]
| TRData String [TyRep]
data TyDecl = TD String [String] [ConRep]
data ConRep = CR String (Maybe [String]) [TyRep]
class Types a where
ty :: a -> TySpec
listDef :: TyDecl
maybeDef :: TyDecl
eitherDef :: TyDecl
merge :: [TyDecl] -> [TyDecl] -> [TyDecl]
merges :: [[TyDecl]] -> [TyDecl]
class TID a where
tid :: a -> ShowS
Documentation
data TySpec Source
A type specification consists of a type representation TyRep and a list of type declarations.
Constructors
TS TyRep [TyDecl]
data TyRep Source
A type representation is built from base types, type variables, tuples, and references to data-defined types.
Constructors
TRBase String
TRVar String
TRTuple [TyRep]
TRData String [TyRep]
data TyDecl Source
A data declaration consists of the name of the data type, a list of type variables, and a list of constructor representations.
Constructors
TD String [String] [ConRep]
data ConRep Source
A constructor is represented by its name, a list of field names (if defined using record notation), and the list of its argument types
Constructors
CR String (Maybe [String]) [TyRep]
class Types a whereSource
Methods
ty :: a -> TySpecSource
listDef :: TyDeclSource
maybeDef :: TyDeclSource
eitherDef :: TyDeclSource
merge :: [TyDecl] -> [TyDecl] -> [TyDecl]Source
merges :: [[TyDecl]] -> [TyDecl]Source
class TID a whereSource
Methods
tid :: a -> ShowSSource
Produced by Haddock version 2.6.0