packages feed

type-functions (empty) → 0.0.0.0

raw patch · 4 files changed

+136/−0 lines, 4 filesdep +basedep +kindssetup-changed

Dependencies added: base, kinds

Files

+ LICENSE view
@@ -0,0 +1,25 @@+Copyright © 2009–2010 Brandenburgische Technische Universität Cottbus+All rights reserved.++Redistribution and use in source and binary forms, with or without modification, are permitted+provided that the following conditions are met:++    • Redistributions of source code must retain the above copyright notice, this list of conditions+      and the following disclaimer.++    • Redistributions in binary form must reproduce the above copyright notice, this list of+      conditions and the following disclaimer in the documentation and/or other materials provided+      with the distribution.++    • Neither the name of the copyright holders nor the names of the contributors may be used to+      endorse or promote products derived from this software without specific prior written+      permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF+THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,4 @@+#!/usr/bin/env runghc++> import Distribution.Simple+> main = defaultMain
+ src/Data/TypeFun.hs view
@@ -0,0 +1,77 @@+module Data.TypeFun (++    TypeFun (type Domain),+    App,+    WrappedApp (WrapApp),+    unwrapApp,+    Universal,+    Id,+    Const++) where++    import Data.Kind as Kind++    {-|+        Type-level functions are represented by types. @TypeFun@ is the class of all function+        representations.++        Note that the @(->)@ instance of @TypeFun@ slightly abuses the type+        constructor @(->)@. In representations of type-level functions, @(->)@ denotes the+        lifting of the type constructor @(->)@. That is if @/r/@ and @/r'/@ are+        representations of functions @/f/@ and @/f'/@, the type @/r/ -> /r'/@ represents+        the function @\\t -> (/f/ t -> /f'/ t)@.+    -}+    class (Kind (Domain fun)) => TypeFun fun where++        {-|+            The domain of the type-level function as a subkind representation. Subkind handling is+            provided by the /kinds/ package.+        -}+        type Domain fun++    instance (TypeFun fun, TypeFun fun', Domain fun ~ Domain fun') => TypeFun (fun -> fun') where++        type Domain (fun -> fun') = Domain fun++    type instance App (fun -> fun') arg = App fun arg -> App fun' arg++    {-|+        Application of type-level functions. @App@ takes a function representation and an argument+        and returns the corresponding result.+    -}+    type family App fun arg++    -- |A data type that is isomorphic to the type synonym family 'App'.+    newtype WrappedApp fun arg = WrapApp (App fun arg)++    -- |The inverse of 'WrapApp'.+    unwrapApp :: WrappedApp fun arg -> App fun arg+    unwrapApp (WrapApp val) = val++    -- |Turns a type-level function into the intersection of all its results.+    type Universal fun = forall arg. (Inhabitant (Domain fun) arg) => WrappedApp fun arg++    {-|+        A type @Id /d/@ represents the type-level identity function whose domain is represented+        by /d/.+    -}+    data Id dom++    instance (Kind dom) => TypeFun (Id dom) where++        type Domain (Id dom) = dom++    type instance App (Id dom) arg = arg++    {-|+        A type @Const /d/ /v/@ represents the constant type-level function whose domain is+        represented by /d/, and whose result is @/v/@.+    -}+    data Const dom val++    instance (Kind dom) => TypeFun (Const dom val) where++        type Domain (Const dom val) = dom++    type instance App (Const dom val) arg = val
+ type-functions.cabal view
@@ -0,0 +1,30 @@+Name:          type-functions+Version:       0.0.0.0+Cabal-Version: >= 1.2.3+Build-Type:    Simple+License:       BSD3+License-File:  LICENSE+Copyright:     © 2009–2010 Brandenburgische Technische Universität Cottbus+Author:        Wolfgang Jeltsch+Maintainer:    jeltsch@tu-cottbus.de+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+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&#xA0;@*@ and whose codomain is&#xA0;@*@+               itself can be represented.+Category:      Type System+Tested-With:   GHC == 6.10.4++Library+    Build-Depends:   base  >= 3.0 && < 4.1,+                     kinds >= 0.0 && < 0.1+    Extensions:      EmptyDataDecls+                     FlexibleContexts+                     Rank2Types+                     TypeFamilies+                     UndecidableInstances+    Exposed-Modules: Data.TypeFun+    HS-Source-Dirs:  src