on 77cb83c help sign in
.gitignore−1
since splitsnapshots
unifiedsplit
@@ -2,4 +2,3 @@ dist
2TAGS
2TAGS
3.cabal-sandbox
3.cabal-sandbox
4cabal.sandbox.config
4cabal.sandbox.config
5−.stack-work
CHANGELOG.md−15
@@ -4,20 +4,5 @@
4
4
5# CHANGELOG
5# CHANGELOG
6
6
7−## 0.1.2
8−### Added KnownPeano
9−
10−## 0.1.1
11−### Fixed
12−* Compilable with ghc-8.0.1
13−
14−## 0.1.0
15−### Added
16−* Type family `Substract` to remove elements of one list from another
17−* Unsafe helper functions to relax constraints in some safe points. But we use
18− `unsafeCoerce` so this functions are potentially just break constants
19−### Changed
20−* Compilable under ghc-7.8
21−
22## 0.0.1
7## 0.0.1
23First version
8First version
example/Main.hs−1
@@ -37,5 +37,4 @@ main = do
37 print $ prefixConstr p2
37 print $ prefixConstr p2
38 print $ prefixConstr p3
38 print $ prefixConstr p3
39 print $ uniqConstr p2
39 print $ uniqConstr p2
40− print $ peanoVal (Proxy :: Proxy (FromNat 100))
41 -- print $ uniqConstr p3 -- < ElementIsNotUniqInList Int '[Int, Bool, Int]
40 -- print $ uniqConstr p3 -- < ElementIsNotUniqInList Int '[Int, Bool, Int]
src/TypeFun/Data/List.hs−17
@@ -40,9 +40,6 @@ module TypeFun.Data.List
40 , ElementIsUniq
40 , ElementIsUniq
41 , UniqElements
41 , UniqElements
42 , UniqElements'
42 , UniqElements'
43− -- * Unsafe helpers
44− , appendId
45− , subListId
46 ) where
43 ) where
47
44
48import Data.Type.Bool
45import Data.Type.Bool
@@ -51,7 +48,6 @@ import GHC.TypeLits
51import TypeFun.Data.Eq
48import TypeFun.Data.Eq
52import TypeFun.Data.Maybe
49import TypeFun.Data.Maybe
53import TypeFun.Data.Peano
50import TypeFun.Data.Peano
54−import Unsafe.Coerce
55
51
56------------------------------------------------------------------------
52------------------------------------------------------------------------
57-- NOTE: Errors type classes. These type classes are not in separate --
53-- NOTE: Errors type classes. These type classes are not in separate --
@@ -108,13 +104,6 @@ type family (:++:) (a :: [k]) (b :: [k]) :: [k] where
108 '[] :++: b = b
104 '[] :++: b = b
109 (a ': as) :++: b = a ': (as :++: b)
105 (a ': as) :++: b = a ': (as :++: b)
110
106
111−appendId
112− :: forall proxy l r
113− . proxy l
114− -> (l ~ (l :++: '[]) => r)
115− -> r
116−appendId = unsafeCoerce id
117−
118type IndexOf a s = FromJust (IndexOfMay a s)
107type IndexOf a s = FromJust (IndexOfMay a s)
119
108
120type IndexOfMay a s = IndexOfMay' Z a s
109type IndexOfMay a s = IndexOfMay' Z a s
@@ -168,12 +157,6 @@ type family SubList (a :: [k]) (b :: [k]) :: Constraint where
168 SubList '[] bs = ()
157 SubList '[] bs = ()
169 SubList (a ': as) bs = (Elem a bs, SubList as bs)
158 SubList (a ': as) bs = (Elem a bs, SubList as bs)
170
159
171−subListId
172− :: forall proxy l r
173− . proxy l
174− -> (SubList l l => r) -> r
175−subListId _ = unsafeCoerce id
176−
177type family NotSubList (a :: [k]) (b :: [k]) :: Constraint where
160type family NotSubList (a :: [k]) (b :: [k]) :: Constraint where
178 NotSubList '[] bs = ()
161 NotSubList '[] bs = ()
179 NotSubList (a ': as) bs = (NotElem a bs, NotSubList as bs)
162 NotSubList (a ': as) bs = (NotElem a bs, NotSubList as bs)
src/TypeFun/Data/Peano.hs+3−14
@@ -1,6 +1,5 @@
1module TypeFun.Data.Peano
1module TypeFun.Data.Peano
2 ( N(..)
2 ( N(..)
3− , KnownPeano(..)
4 , ToNat
3 , ToNat
5 , FromNat
4 , FromNat
6 , (:+:)
5 , (:+:)
@@ -8,24 +7,14 @@ module TypeFun.Data.Peano
8 , (:*:)
7 , (:*:)
9 ) where
8 ) where
10
9
11−import Data.Typeable
10+import Data.Typeable
12−import GHC.Generics (Generic)
11+import GHC.Generics (Generic)
13−import GHC.TypeLits
12+import GHC.TypeLits
14
13
15data N = Z | S N
14data N = Z | S N
16 deriving ( Eq, Ord, Read, Show
15 deriving ( Eq, Ord, Read, Show
17 , Generic, Typeable )
16 , Generic, Typeable )
18
17
19−-- | @since 0.1.2
20−class KnownPeano (p :: N) where
21− peanoVal :: proxy p -> Integer
22−
23−instance KnownPeano Z where
24− peanoVal _ = 0
25−
26−instance (KnownPeano n) => KnownPeano (S n) where
27− peanoVal _ = succ $ peanoVal (Proxy :: Proxy n)
28−
29type family ToNat (a :: N) :: Nat where
18type family ToNat (a :: N) :: Nat where
30 ToNat Z = 0
19 ToNat Z = 0
31 ToNat (S a) = 1 + (ToNat a)
20 ToNat (S a) = 1 + (ToNat a)
stack.yamldeleted−9
@@ -1,9 +0,0 @@
1−nix:
2− packages:
3− - zlib
4− - postgresql
5−
6−resolver: lts-13.21
7−
8−packages:
9− - .
stack.yaml.lockdeleted−12
@@ -1,12 +0,0 @@
1−# This file was autogenerated by Stack.
2−# You should not edit this file by hand.
3−# For more information, please see the documentation at:
4−# https://docs.haskellstack.org/en/stable/lock_files
5−
6−packages: []
7−snapshots:
8−- completed:
9− size: 498180
10− url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/21.yaml
11− sha256: eff2de19a6d4691ccbf6edc1fba858f1918683047dce0f09adede874bbd2a8f3
12− original: lts-13.21
type-fun.cabal+4−7
@@ -1,5 +1,5 @@
1name: type-fun
1name: type-fun
2−version: 0.1.2
2+version: 0.0.1
3synopsis: Collection of widely reimplemented type families
3synopsis: Collection of widely reimplemented type families
4license: BSD3
4license: BSD3
5license-file: LICENSE
5license-file: LICENSE
@@ -19,13 +19,10 @@ library
19 hs-source-dirs: src
19 hs-source-dirs: src
20 default-extensions: ConstraintKinds
20 default-extensions: ConstraintKinds
21 , DataKinds
21 , DataKinds
22− , DeriveDataTypeable
23 , DeriveGeneric
22 , DeriveGeneric
24 , FlexibleInstances
23 , FlexibleInstances
25 , MultiParamTypeClasses
24 , MultiParamTypeClasses
26 , PolyKinds
25 , PolyKinds
27− , RankNTypes
28− , ScopedTypeVariables
29 , TypeFamilies
26 , TypeFamilies
30 , TypeOperators
27 , TypeOperators
31 , UndecidableInstances
28 , UndecidableInstances
@@ -36,15 +33,15 @@ library
36 , TypeFun.Data.Maybe
33 , TypeFun.Data.Maybe
37 , TypeFun.Data.Peano
34 , TypeFun.Data.Peano
38
35
39− build-depends: base >= 4.7 && < 5
36+ build-depends: base >=4.7 && <4.9
37+
40
38
41test-suite example
39test-suite example
42 type: exitcode-stdio-1.0
40 type: exitcode-stdio-1.0
43 default-language: Haskell2010
41 default-language: Haskell2010
44 hs-source-dirs: example
42 hs-source-dirs: example
45 main-is: Main.hs
43 main-is: Main.hs
46− default-extensions: ConstraintKinds
44+ default-extensions: DataKinds
47− , DataKinds
48 , GADTs
45 , GADTs
49 , TemplateHaskell
46 , TemplateHaskell
50 , TypeFamilies
47 , TypeFamilies