The latest version of open-typerep is 0.6.1-0.

open-typerep

Version 0.2 revision 0 uploaded by EmilAxelsson.

Package meta

Synopsis
Open type representations and dynamic types
Description

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.

Author
Emil Axelsson
Bug reports
https://github.com/emilaxelsson/open-typerep/issues
Category
Dependent Types
Copyright
Copyright (c) 2014, Emil Axelsson
Homepage
https://github.com/emilaxelsson/open-typerep
Maintainer
emax@chalmers.se
Package URL
n/a
Stability
experimental

Components