The open-typerep package

[Tags: bsd3, library]

This package uses Data Types à la Carte to provide open type representations and dynamic types/coercions for open type universes.

Example 1 (dynamic types):

 type MyUniverse = IntType :+: BoolType

 hlist :: [Dynamic MyUniverse]
 hlist = [toDyn True, toDyn (1 :: Int)]
 *Main> hlist
 [True,1]

Note that if we were using Data.Dynamic, it would just print

 [<<Bool>>,<<Int>>]

Example 2 (dynamically typed addition):

 addDyn :: (TypeEq ts ts, PWitness Num ts ts) => Dynamic ts -> Dynamic ts -> Maybe (Dynamic ts)
 addDyn (Dyn ta a) (Dyn tb b) = do
     Dict <- typeEq ta tb
     Dict <- pwit pNum ta
     return (Dyn ta (a+b))

Data.Dynamic could only do this monomorphically, for one Num type at a time.


Properties

Version0.1
Dependenciesbase (==4.*), constraints (>=0.3), syntactic (>=2.0), tagged (>=0.4)
LicenseBSD3
CopyrightCopyright (c) 2014, Emil Axelsson
AuthorEmil Axelsson
Maintaineremax@chalmers.se
Stabilityexperimental
CategoryDependent Types
Home pagehttps://github.com/emilaxelsson/open-typerep
Bug trackerhttps://github.com/emilaxelsson/open-typerep/issues
Source repositoryhead: git clone https://github.com/emilaxelsson/open-typerep
Upload dateTue Jul 1 13:44:51 UTC 2014
Uploaded byEmilAxelsson
Downloads55 total (11 in last 30 days)

Modules

Downloads

Maintainers' corner

For package maintainers and hackage trustees