packages feed

type-list 0.0.0.1 → 0.1.0.0

raw patch · 3 files changed

+53/−58 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Data.Type.List: class TypeLength xs
- Data.Type.List: instance TypeLength '[]
- Data.Type.List: instance TypeLength xs => TypeLength (x : xs)
- Data.Type.List: typeLength :: TypeLength xs => sing xs -> Int
+ Data.Type.List: Length' :: Length' l
+ Data.Type.List: data Length' :: TyFun [a] Nat -> *

Files

LICENSE view
@@ -1,30 +1,28 @@-Copyright (c) 2014, Marcin Mrotek--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 Marcin Mrotek nor the names of other-      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-OWNER 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.+Copyright (c) 2015, Marcin Mrotek
+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 type-list nor the names of its
+  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 HOLDER 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.
+
src/Data/Type/List.hs view
@@ -23,6 +23,7 @@  module Data.Type.List where +import GHC.TypeLits import Data.Type.Bool import Data.Type.Equality import Data.Singletons@@ -41,15 +42,14 @@ type instance Apply Map'' f = Map' f type instance Apply (Map' f) l = Map f l --- |Length of a type-level list, accesible at runtime.-class TypeLength xs where-    typeLength :: sing xs -> Int+type family Length xs where+    Length '[] = 0+    Length (x ': xs) = 1 + (Length xs) -instance TypeLength '[] where-    typeLength _ = 0+data Length' :: TyFun [a] Nat -> * where+    Length' :: Length' l -instance TypeLength xs => TypeLength (x ': xs) where-    typeLength _ = (typeLength (undefined :: sing xs)) + 1+type instance Apply Length' xs = Length xs  -- |Insert a type into a type list. type family Insert a xs where@@ -95,7 +95,6 @@ type instance Apply Remove'' x = Remove' x type instance Apply (Remove' x) xs = Remove x xs --- |Set difference of two lists. type family Difference xs ys where     Difference '[] ys = ys     Difference (x ': xs) ys = Remove x (Difference xs ys)@@ -109,12 +108,10 @@ type instance Apply Difference'' xs = Difference' xs type instance Apply (Difference' xs) ys = Difference xs ys --- |Helper function for Reverse. type family ReverseAcc xs acc where     ReverseAcc '[] acc = acc     ReverseAcc (x ': xs) acc = ReverseAcc xs (x ': acc) --- |Reverse a type list. type family Reverse xs where     Reverse xs = ReverseAcc xs '[] @@ -123,21 +120,6 @@  type instance Apply Reverse' xs = Reverse xs --- | Type list intersection. -type family Intersection xs ys where-    Intersection '[] ys = '[]-    Intersection (x ': xs) (x ': ys) = x ': (Intersection xs ys)-    Intersection (x ': xs) (y ': ys) = Intersection xs ys--data Intersection'' :: TyFun [k] (TyFun [k] [k] -> *) -> * where-    Intersection'' :: Intersection'' f--data Intersection' :: [k] -> TyFun [k] [k] -> * where-    Intersection' :: Intersection' xs f--type instance Apply Intersection'' xs = Intersection' xs-type instance Apply (Intersection' xs) ys = Intersection xs ys- -- | Type list membership test. type family Find x ys where     Find x '[]       = False@@ -152,6 +134,21 @@  type instance Apply Find'' x = Find' x type instance Apply (Find' x) xs = Find x xs++-- | Type list intersection. +type family Intersection xs ys where+    Intersection '[] ys = '[]+    Intersection (x ': xs) (x ': ys) = x ': (Intersection xs ys)+    Intersection (x ': xs) (y ': ys) = If (Find x ys) (x ': (Intersection xs (y ': ys))) (Intersection xs (y ': ys))++data Intersection'' :: TyFun [k] (TyFun [k] [k] -> *) -> * where+    Intersection'' :: Intersection'' f++data Intersection' :: [k] -> TyFun [k] [k] -> * where+    Intersection' :: Intersection' xs f++type instance Apply Intersection'' xs = Intersection' xs+type instance Apply (Intersection' xs) ys = Intersection xs ys  -- |Test if two list do not contain any equal elements. type family Distinct xs ys where
type-list.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                type-list-version:             0.0.0.1+version:             0.1.0.0 synopsis:            Operations on type-level lists and tuples. description:         Operations on type-level lists and tuples, together with their curried versions. license:             BSD3@@ -15,8 +15,8 @@ -- extra-source-files:   cabal-version:       >=1.10 source-repository    head-    type: darcs-    location: mjm@hub.darcs.net:mjm/type-list+    type: git+    location: https://github.com/marcinmrotek/type-list  library   exposed-modules:     Data.Type.List