packages feed

haskus-utils-types 1.1 → 1.2

raw patch · 3 files changed

+42/−33 lines, 3 filesdep ~base

Dependency ranges changed: base

Files

haskus-utils-types.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.20 name: haskus-utils-types-version: 1.1+version: 1.2 license: BSD3 license-file: LICENSE copyright: Sylvain Henry 2018
src/lib/Haskus/Utils/Types.hs view
@@ -68,7 +68,7 @@ -- | Like: If cond t (TypeError msg) -- -- The difference is that the TypeError doesn't appear in the RHS of the type--- which lead to better error messages (see GHC #14771).+-- which leads to better error messages (see GHC #14771). -- -- For instance: --    type family F n where
src/lib/Haskus/Utils/Types/List.hs view
@@ -10,45 +10,54 @@  -- | Utils for type lists module Haskus.Utils.Types.List-   ( Map-   , Max+   (+   -- * Construction+     Snoc+   , Concat+   , Replicate+   , Zip+   -- * Removal+   , RemoveAt+   , RemoveAt1+   , RemoveAtN+   , Remove+   , Nub+   , NubHead+   -- * Sublist+   , Head    , Tail-   , Drop-   , Take    , Init-   , Head-   , Snoc+   , Take+   , Drop+   -- * Insert/replace    , InsertAt    , ReplaceAt    , Replace    , ReplaceN    , ReplaceNS-   , Reverse-   , RemoveAt-   , RemoveAt1-   , RemoveAtN-   , Concat-   , Length-   , Replicate-   , Generate+   -- * Set operations    , IsMember    , IsSubset-   , Indexes-   , MapTest-   , Zip-   , Filter-   , Nub-   , NubHead-   , IndexOf-   , IndexesOf-   , MaybeIndexOf-   , Index    , Union    , Complement    , Product    , Member    , Member'    , CheckNub+   -- * Index operations+   , IndexOf+   , IndexesOf+   , MaybeIndexOf+   , Index+   , Reverse+   -- * Nat list+   , Generate+   -- * Others+   , Map+   , Max+   , Length+   , Indexes+   , MapTest    ) where @@ -224,10 +233,10 @@    Zip (x ': xs) (y ': ys) = (x,y) ': Zip xs ys  -- | Remove `a` in `l`-type family Filter (a :: k) (l :: [k]) :: [k] where-   Filter a '[]       = '[]-   Filter a (a ': as) = Filter a as-   Filter a (b ': as) = b ': Filter a as+type family Remove (a :: k) (l :: [k]) :: [k] where+   Remove a '[]       = '[]+   Remove a (a ': as) = Remove a as+   Remove a (b ': as) = b ': Remove a as  -- | Keep only a single value of each type type family Nub (l :: [k]) :: [k] where@@ -235,12 +244,12 @@  type family Nub' (as :: [k]) (xs :: [k]) :: [k] where    Nub' '[]       xs = xs-   Nub' (x ': as) xs = Nub' (Filter x as) (x ': xs) +   Nub' (x ': as) xs = Nub' (Remove x as) (x ': xs)   -- | Keep only a single value of the head type type family NubHead (l :: [k]) :: [k] where    NubHead '[]       = '[]-   NubHead (x ': xs) = x ': Filter x xs+   NubHead (x ': xs) = x ': Remove x xs  -- | Get the first index of a type type family IndexOf (a :: k) (l :: [k]) :: Nat where@@ -283,7 +292,7 @@ -- | Complement xs \ ys type family Complement (xs :: [k]) (ys :: [k]) :: [k] where    Complement xs '[]    = xs-   Complement xs (y:ys) = Complement (Filter y xs) ys+   Complement xs (y:ys) = Complement (Remove y xs) ys  -- | Product of two lists type family Product (xs :: [*]) (ys :: [*]) :: [*] where