type-functions 0.1.0.0 → 0.2.0.0
raw patch · 2 files changed
+32/−9 lines, 2 files
Files
- src/Data/TypeFun.hs +26/−6
- type-functions.cabal +6/−3
src/Data/TypeFun.hs view
@@ -1,13 +1,15 @@+-- | Emulation of type-level functions. module Data.TypeFun ( -- * Type-level functions in general TypeFun (type Domain), App, - -- * Specific type-level functions+ -- * Construction of type-level functions Id (Id), Const (Const), (:->) ((:->)),+ FunMap, -- * Utilities WrappedApp (WrapApp),@@ -18,6 +20,11 @@ import Data.Kind as Kind + {-NOTE:+ At the value level, type-level function representations contain other /representations/ but+ nothing else.+ -}+ -- * Type-level functions in general {-| Type-level functions are represented by types. @TypeFun@ is the class of all type-level@@ -37,12 +44,12 @@ -} type family App fun arg - -- * Specific type-level functions+ -- * Construction of type-level functions infixr 1 :-> {-| A type @Id /d/@ represents the type-level identity function whose domain is represented- by /d/.+ by @/d/@. -} data Id dom = Id dom @@ -54,9 +61,9 @@ {-| A type @Const /d/ /v/@ represents the constant type-level function whose domain is- represented by /d/, and whose result is @/v/@.+ represented by @/d/@, and whose result is @/v/@. -}- data Const dom val = Const dom val+ data Const dom val = Const dom instance (Kind dom) => TypeFun (Const dom val) where @@ -65,7 +72,8 @@ type instance App (Const dom val) arg = val {-|- A type @/f/ :-> /f'/@ represents the type-level function @\\arg -> (/f/ arg -> /f'/ arg)@.+ A type @/f/ :-> /f'/@ represents the type-level function @\\arg -> ('App' /f/ arg -> 'App'+ /f'/ arg)@. -} data fun :-> fun' = fun :-> fun' @@ -74,6 +82,18 @@ type Domain (fun :-> fun') = Domain fun type instance App (fun :-> fun') arg = App fun arg -> App fun' arg++ {-|+ If @/t/@ is a type of kind @* -> *@, and @/f/@ is the representation of a+ type-level function, @FunMap /t/ /f/@ represents the function @\\arg -> /t/ (App /f/ arg)@.+ -}+ data FunMap (trans :: * -> *) fun = FunMap fun++ instance (TypeFun fun) => TypeFun (FunMap trans fun) where++ type Domain (FunMap trans fun) = Domain fun++ type instance App (FunMap trans fun) arg = trans (App fun arg) -- * Utilities -- |A data type that is isomorphic to the type synonym family 'App'.
type-functions.cabal view
@@ -1,5 +1,5 @@ Name: type-functions-Version: 0.1.0.0+Version: 0.2.0.0 Cabal-Version: >= 1.2.3 Build-Type: Simple License: BSD3@@ -10,13 +10,16 @@ Stability: provisional Homepage: http://community.haskell.org/~jeltsch/type-functions/ Bug-Reports: jeltsch@tu-cottbus.de-Package-URL: http://hackage.haskell.org/packages/archive/type-functions/0.0.0.0/type-functions-0.0.0.0.tar.gz+Package-URL: http://hackage.haskell.org/packages/archive/type-functions/0.2.0.0/type-functions-0.2.0.0.tar.gz Synopsis: Emulation of type-level functions Description: This package supports emulation of type-level functions using defunctionalization. All functions whose domain is a subkind of @*@ and whose codomain is @*@ itself can be represented.+ .+ For detailed information, please refer to Subsection 3.2 of the paper+ /Generic Record Combinators with Static Type Checking/. Category: Type System-Tested-With: GHC == 6.10.4+Tested-With: GHC == 6.12.1 Library Build-Depends: base >= 3.0 && < 4.1,