nthese 0.1.0.0 → 0.1.0.1
raw patch · 2 files changed
+9/−5 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- nthese.cabal +1/−1
- src/Data/NThese.hs +8/−4
nthese.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: nthese-version: 0.1.0.0+version: 0.1.0.1 synopsis: A heterogeneous, n-ary generalisation of These description: `NThese` is an n-ary generalisation of the `These` datatype,
src/Data/NThese.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableSuperClasses #-} -module Data.NThese (module Data.NThese) where+module Data.NThese where -- base import Data.Function ((&))@@ -24,6 +24,8 @@ -- semialign import Data.Align (Align (..), Semialign (..), Unalign (..)) +-- * 'NThese'+ {- | An n-ary generalisation of the 'These' datatype. @'NThese' f [a1, a2, a3, ...]@ contains at least one of @f a1@, @f a2@, and so on,@@ -205,7 +207,7 @@ 'align' has this type signature: @-'align' :: Semialign f => f a -> f b -> f ('These' a b)+'align' :: 'Align' f => f a -> f b -> f ('These' a b) @ This generalises zipping 2 @f@-structures, and requiring that at each @f@-position we have either an @a@ or a @b@.@@ -213,7 +215,7 @@ 'alignN' generalises this in two directions: 1. Incidental: We use nested @f (g a)@-structures. (But @g@ can always be set to identity, and is thus irrelevant.)-1. Crucial: We have @n@ values instead of 2. At each @f@-position we can have 1 to n values.+2. Crucial: On the input, we have @n@ values instead of 2. In the output, at each @f@-position we can have 1 to n values. -} alignN :: forall a as f g. (SListI as, Semialign f) => NP (f :.: g) (a : as) -> f (NThese g (a : as)) alignN = \case@@ -243,7 +245,7 @@ 'unalign' has this type signature: @-unalign :: Unalign f => f (These a b) -> (f a, f b)+'unalign' :: 'Unalign' f => f (These a b) -> (f a, f b) @ Similar to 'alignN' we generalise this from 2 values to @n@ values.@@ -259,6 +261,8 @@ type instance Same NThese = NThese type instance Prod NThese = NP++-- * Helpers -- | Helper class to constrain the type level list on 'NThese' always to be nonempty class (SListI as) => SListINThese as