packages feed

type-fun 0.0.1 → 0.1.0

raw patch · 3 files changed

+38/−3 lines, 3 files

Files

CHANGELOG.md view
@@ -4,5 +4,13 @@  # CHANGELOG +## 0.1.0+### Added+* Type family `Substract` to remove elements of one list from another+* Unsafe helper functions to relax constraints in some safe points. But we use+  `unsafeCoerce` so this functions are potentially just break constants+### Changed+* Compilable under ghc-7.8+ ## 0.0.1 First version
src/TypeFun/Data/List.hs view
@@ -35,10 +35,14 @@   , UnionList   , AppendUniq   , Intersect+  , Substract     -- * Uniqueness checking   , ElementIsUniq   , UniqElements   , UniqElements'+    -- * Unsafe helpers+  , appendId+  , subListId   ) where  import Data.Type.Bool@@ -47,6 +51,7 @@ import TypeFun.Data.Eq import TypeFun.Data.Maybe import TypeFun.Data.Peano+import Unsafe.Coerce  ------------------------------------------------------------------------ -- NOTE: Errors type classes. These type classes are not in separate  --@@ -103,6 +108,13 @@   '[] :++: b = b   (a ': as) :++: b = a ': (as :++: b) +appendId+  :: forall proxy l r+   . proxy l+  -> (l ~ (l :++: '[]) => r)+  -> r+appendId = unsafeCoerce id+ type IndexOf a s = FromJust (IndexOfMay a s)  type IndexOfMay a s = IndexOfMay' Z a s@@ -156,6 +168,12 @@   SubList '[]       bs = ()   SubList (a ': as) bs = (Elem a bs, SubList as bs) +subListId+  :: forall proxy l r+   . proxy l+  -> (SubList l l => r) -> r+subListId _ = unsafeCoerce id+ type family NotSubList (a :: [k]) (b :: [k]) :: Constraint where   NotSubList '[]       bs = ()   NotSubList (a ': as) bs = (NotElem a bs, NotSubList as bs)@@ -194,6 +212,12 @@ -- | Calculates intersection between two lists. Order of elements is -- taken from first list type Intersect a b = (Indices (CatMaybes (IndicesOfMay a b)) b)++-- | Removes from first list all elements occured in second+type family Substract (a :: [k]) (b :: [k]) :: [k] where+  Substract '[] b = '[]+  Substract a '[] = a+  Substract a (b ': bs) = Substract (Delete b a) bs  -- | Checks that element 'a' occurs in a list just once type ElementIsUniq a s = If (Equal (S Z) (Count a s))
type-fun.cabal view
@@ -1,5 +1,5 @@ name:                type-fun-version:             0.0.1+version:             0.1.0 synopsis:            Collection of widely reimplemented type families license:             BSD3 license-file:        LICENSE@@ -19,10 +19,13 @@   hs-source-dirs:      src   default-extensions:  ConstraintKinds                      , DataKinds+                     , DeriveDataTypeable                      , DeriveGeneric                      , FlexibleInstances                      , MultiParamTypeClasses                      , PolyKinds+                     , RankNTypes+                     , ScopedTypeVariables                      , TypeFamilies                      , TypeOperators                      , UndecidableInstances@@ -35,13 +38,13 @@    build-depends:       base >=4.7 && <4.9 - test-suite example   type:               exitcode-stdio-1.0   default-language:   Haskell2010   hs-source-dirs:     example   main-is:            Main.hs-  default-extensions: DataKinds+  default-extensions: ConstraintKinds+                    , DataKinds                     , GADTs                     , TemplateHaskell                     , TypeFamilies