Safe Haskell | None |
---|---|
Language | Haskell2010 |
The Conkin
module defines tools for types of kind (k -> *) -> *
(continuation kind types), treating them as functors from the category of
types of kind k -> *
(Hask^k) to the category of types of kind *
(Hask).
It defines its own Functor
, Applicative
, Foldable
, and Traversable
classes, as continuation kind types are kind-incompatible with the
homonymous classes in Prelude.
The Dispose
type lifts a traditional functor to a continuation kind
functor:
>>>
:k Dispose Maybe 0
Dispose Maybe 0 :: (Nat -> *) -> *
While the Coyoneda
type does the opposite.
>>>
data OfSymbol a = OfSymbol (a "hello")
>>>
:k OfSymbol
OfSymbol :: (Symbol -> *) -> *>>>
:k Coyoneda OfSymbol
Coyoneda OfSymbol :: * -> *
Two of the most useful functions provided by the module are align
and
apportion
, as they allow you to transpose the composition of a traditional
endofunctor and a continuation kind functor.
>>>
rows = zipWith (\ch ix -> Pair (Identity ch, Identity ix)) "abc" [0..2]
>>>
rows
[ Pair { getPair = ( Identity 'a' , Identity 0 ) } , Pair { getPair = ( Identity 'b' , Identity 1 ) } , Pair { getPair = ( Identity 'c' , Identity 2 ) } ]>>>
cols = align rows
>>>
cols
Pair { getPair = ( "abc" , [ 0 , 1 , 2 ] ) }>>>
apportion cols
[ Pair { getPair = ( Identity 'a' , Identity 0 ) } , Pair { getPair = ( Identity 'a' , Identity 1 ) } , Pair { getPair = ( Identity 'a' , Identity 2 ) } , Pair { getPair = ( Identity 'b' , Identity 0 ) } , Pair { getPair = ( Identity 'b' , Identity 1 ) } , Pair { getPair = ( Identity 'b' , Identity 2 ) } , Pair { getPair = ( Identity 'c' , Identity 0 ) } , Pair { getPair = ( Identity 'c' , Identity 1 ) } , Pair { getPair = ( Identity 'c' , Identity 2 ) } ]>>>
apportion $ fmap ZipList cols
ZipList { getZipList = [ Pair { getPair = ( Identity 'a' , Identity 0 ) } , Pair { getPair = ( Identity 'b' , Identity 1 ) } , Pair { getPair = ( Identity 'c' , Identity 2 ) } ] }
There's also convenience types for Product
s and Coproduct
s of
continuation kind functors, as well as for Tuple
s and Tagged
unions
of arbitrary types.
- class Functor f where
- (<$>) :: Functor f => (forall x. a x -> b x) -> f a -> f b
- class Functor f => Applicative f where
- newtype (a ~> b) x = Arrow {
- (~$~) :: a x -> b x
- liftA2 :: Applicative f => (forall x. a x -> b x -> c x) -> f a -> f b -> f c
- liftA3 :: Applicative f => (forall x. a x -> b x -> c x -> d x) -> f a -> f b -> f c -> f d
- liftA4 :: Applicative f => (forall x. a x -> b x -> c x -> d x -> e x) -> f a -> f b -> f c -> f d -> f e
- class Foldable t where
- class (Foldable t, Functor t) => Traversable t where
- traverse' :: (Traversable t, Applicative f) => (forall x. a x -> f (Flip b x)) -> t a -> f (Compose t b)
- sequenceA' :: (Traversable t, Applicative f) => t (Compose f (Flip a)) -> f (Compose t a)
- liftT1 :: Applicative g => (forall h. h w -> f h) -> Compose g a w -> g (Compose f (Flip a))
- liftT2 :: Applicative g => (forall h. h w -> h x -> f h) -> Compose g a w -> Compose g a x -> g (Compose f (Flip a))
- liftT3 :: Applicative g => (forall h. h w -> h x -> h y -> f h) -> Compose g a w -> Compose g a x -> Compose g a y -> g (Compose f (Flip a))
- liftT4 :: Applicative g => (forall h. h w -> h x -> h y -> h z -> f h) -> Compose g a w -> Compose g a x -> Compose g a y -> Compose g a z -> g (Compose f (Flip a))
- align :: (Traversable f, Applicative g) => f (g Identity) -> g f
- apportion :: (Applicative f, Traversable g) => g f -> f (g Identity)
- newtype Dispose f x a = Dispose {
- getDispose :: f (a x)
- data Coyoneda t u where
- getCoyoneda :: Functor t => Coyoneda t a -> t (Const a)
- toCoyoneda :: t (Const a) -> Coyoneda t a
- newtype Product f g a = Product {
- getProduct :: f (Compose g (Curry a))
- toProduct :: (Functor f, Functor g) => (forall x y. a x y -> b '(x, y)) -> f (Compose g a) -> Product f g b
- fromProduct :: (Functor f, Functor g) => (forall x y. b '(x, y) -> a x y) -> Product f g b -> f (Compose g a)
- newtype Coproduct f g a = Coproduct {
- getCoproduct :: (f (Compose a Left), g (Compose a Right))
- newtype Pair x0 x1 a = Pair {
- getPair :: (a x0, a x1)
- data Tuple xs a where
- data Tagged xs a where
- newtype Flip a y x = Flip {
- getFlip :: a x y
- newtype Curry a x y = Curry {
- getCurry :: a '(x, y)
- newtype Uncurry a z = UncurryLazy {
- getUncurryLazy :: forall x y. z ~ '(x, y) => a x y
- pattern UncurryStrict :: forall k k1 a x y. a x y -> Uncurry k k1 a ((,) k1 k x y)
- getUncurryStrict :: Uncurry a '(x, y) -> a x y
- uncurried :: (forall x y. a x y -> b x y) -> Uncurry a z -> Uncurry b z
- newtype Pure x a = Pure {
- getPure :: a x
Documentation
class Functor f where Source #
A functor from Hask^k to Hask, an analogue of Functor
for kind (k -> *) -> *
Functor k (Pure k x) Source # | |
Functor k (Const (k -> *) a) Source # | |
Functor k (Tagged k xs) Source # | |
Functor k (Tuple k xs) Source # | |
Functor k (Pair k x0 x1) Source # | |
Functor f => Functor k (Dispose k f x) Source # | |
(Functor f, Functor k g) => Functor k (Compose (k -> *) * f g) Source # | |
(Functor i f, Functor j g) => Functor (Either i j) (Coproduct j i f g) Source # | |
(Functor i f, Functor j g) => Functor (i, j) (Product j i f g) Source # | |
class Functor f => Applicative f where Source #
An analogue of Applicative
for kind (k -> *) -> *
Applicative k (Pure k x) Source # | |
Monoid m => Applicative k (Const (k -> *) m) Source # | |
Applicative k (Tuple k xs) => Applicative k (Tuple k ((:) k x xs)) Source # | |
Applicative k (Tuple k ([] k)) Source # | |
Applicative k (Pair k x0 x1) Source # | |
Applicative f => Applicative k (Dispose k f x) Source # | |
(Applicative f, Applicative k g) => Applicative k (Compose (k -> *) * f g) Source # | |
(Applicative i f, Applicative j g) => Applicative (Either i j) (Coproduct j i f g) Source # | |
(Applicative i f, Applicative j g) => Applicative (i, j) (Product j i f g) Source # | |
liftA2 :: Applicative f => (forall x. a x -> b x -> c x) -> f a -> f b -> f c Source #
An analogue of liftA2
for use with Conkin's Applicative
liftA3 :: Applicative f => (forall x. a x -> b x -> c x -> d x) -> f a -> f b -> f c -> f d Source #
An analogue of liftA3
for use with Conkin's Applicative
liftA4 :: Applicative f => (forall x. a x -> b x -> c x -> d x -> e x) -> f a -> f b -> f c -> f d -> f e Source #
An extension of liftA3
to functions of four arguments
class Foldable t where Source #
An analogue of Foldable
for kind (k -> *) -> *
foldr :: (forall x. a x -> b -> b) -> b -> t a -> b Source #
foldMap :: Monoid m => (forall x. a x -> m) -> t a -> m Source #
Foldable k (Pure k x) Source # | |
Foldable k (Const (k -> *) m) Source # | |
Foldable k (Tagged k xs) Source # | |
Foldable k (Tuple k xs) Source # | |
Foldable k (Pair k x0 x1) Source # | |
Foldable t => Foldable k (Dispose k t x) Source # | |
(Foldable f, Foldable k g) => Foldable k (Compose (k -> *) * f g) Source # | |
(Foldable i f, Foldable j g) => Foldable (Either i j) (Coproduct j i f g) Source # | |
(Foldable i f, Foldable j g) => Foldable (i, j) (Product j i f g) Source # | |
class (Foldable t, Functor t) => Traversable t where Source #
An analogue of Traversable
for kind (k -> *) -> *
traverse :: forall f a b. Applicative f => (forall x. a x -> f (b x)) -> t a -> f (Compose t (Flip b)) Source #
sequenceA :: forall f a. Applicative f => t (Compose f a) -> f (Compose t (Flip a)) Source #
Traversable i (Pure i x) Source # | |
Traversable i (Const (i -> *) m) Source # | |
Traversable i (Tagged i xs) Source # | |
Traversable i (Tuple i xs) Source # | |
Traversable i (Pair i x0 x1) Source # | |
Traversable t => Traversable i (Dispose i t x) Source # | |
(Traversable f, Traversable i g) => Traversable i (Compose (i -> *) * f g) Source # | |
(Traversable i f, Traversable j g) => Traversable (Either i j) (Coproduct j i f g) Source # | |
(Traversable i f, Traversable j g) => Traversable (i, j) (Product j i f g) Source # | |
traverse' :: (Traversable t, Applicative f) => (forall x. a x -> f (Flip b x)) -> t a -> f (Compose t b) Source #
version of traverse
that unflips the inner type
sequenceA' :: (Traversable t, Applicative f) => t (Compose f (Flip a)) -> f (Compose t a) Source #
version of sequenceA
that unflips the inner type
liftT1 :: Applicative g => (forall h. h w -> f h) -> Compose g a w -> g (Compose f (Flip a)) Source #
sequenceA
helper for single-parameter constructors
>>>
:{
data OfOne a = OfOne (a Int) instance Functor OfOne where fmap h (OfOne a) = OfOne (h a) instance Applicative OfOne where pure = OfOne OfOne f <*> OfOne a = OfOne (f ~$~ a) instance Foldable OfOne where foldMap h (OfOne a) = h a instance Traversable OfOne where sequenceA (OfOne fa) = liftT1 OfOne fa :}
liftT2 :: Applicative g => (forall h. h w -> h x -> f h) -> Compose g a w -> Compose g a x -> g (Compose f (Flip a)) Source #
sequenceA
helper for two-parameter constructors
>>>
:{
data OfTwo a = OfTwo (a Int) (a Char) instance Functor OfTwo where fmap h (OfTwo ai ac) = OfTwo (h ai) (h ac) instance Applicative OfTwo where pure a = OfTwo a a OfTwo fi fc <*> OfTwo ai ac = OfTwo (fi ~$~ ai) (fc ~$~ ac) instance Foldable OfTwo where foldMap h (OfTwo ai ac) = h ai <> h ac instance Traversable OfTwo where sequenceA (OfTwo fai fac) = liftT2 OfTwo fai fac :}
liftT3 :: Applicative g => (forall h. h w -> h x -> h y -> f h) -> Compose g a w -> Compose g a x -> Compose g a y -> g (Compose f (Flip a)) Source #
sequenceA
helper for three-parameter constructors
>>>
:{
data OfThree a = OfThree (a Int) (a Char) (a Bool) instance Functor OfThree where fmap h (OfThree ai ac ab) = OfThree (h ai) (h ac) (h ab) instance Applicative OfThree where pure a = OfThree a a a OfThree fi fc fb <*> OfThree ai ac ab = OfThree (fi ~$~ ai) (fc ~$~ ac) (fb ~$~ ab) instance Foldable OfThree where foldMap h (OfThree ai ac ab) = h ai <> h ac <> h ab instance Traversable OfThree where sequenceA (OfThree fai fac fab) = liftT3 OfThree fai fac fab :}
liftT4 :: Applicative g => (forall h. h w -> h x -> h y -> h z -> f h) -> Compose g a w -> Compose g a x -> Compose g a y -> Compose g a z -> g (Compose f (Flip a)) Source #
sequenceA
helper for four-parameter constructors
>>>
:{
data OfFour a = OfFour (a Int) (a Char) (a Bool) (a Double) instance Functor OfFour where fmap h (OfFour ai ac ab ad) = OfFour (h ai) (h ac) (h ab) (h ad) instance Applicative OfFour where pure a = OfFour a a a a OfFour fi fc fb fd <*> OfFour ai ac ab ad = OfFour (fi ~$~ ai) (fc ~$~ ac) (fb ~$~ ab) (fd ~$~ ad) instance Foldable OfFour where foldMap h (OfFour ai ac ab ad) = h ai <> h ac <> h ab <> h ad instance Traversable OfFour where sequenceA (OfFour fai fac fab fad) = liftT4 OfFour fai fac fab fad :}
align :: (Traversable f, Applicative g) => f (g Identity) -> g f Source #
Loosely, align
transforms an array of structures into a structure
of arrays, if by "array" one means an arbitrary collection type.
>>>
rows = zipWith (\ch ix -> Pair (Identity ch, Identity ix)) "abc" [0..2]
>>>
rows
[ Pair { getPair = ( Identity 'a' , Identity 0 ) } , Pair { getPair = ( Identity 'b' , Identity 1 ) } , Pair { getPair = ( Identity 'c' , Identity 2 ) } ]>>>
align rows
Pair { getPair = ( "abc" , [ 0 , 1 , 2 ] ) }
apportion :: (Applicative f, Traversable g) => g f -> f (g Identity) Source #
Loosely, apportion
transforms a structure of arrays into an array
of structures, if by "array" one means an arbitrary collection type.
Depending on the collection's Applicative
instance, this
may or may not be the inverse of align
.
>>>
cols = Pair { getPair = ( "abc" , [ 0 , 1 , 2 ] ) }
>>>
apportion cols
[ Pair { getPair = ( Identity 'a' , Identity 0 ) } , Pair { getPair = ( Identity 'a' , Identity 1 ) } , Pair { getPair = ( Identity 'a' , Identity 2 ) } , Pair { getPair = ( Identity 'b' , Identity 0 ) } , Pair { getPair = ( Identity 'b' , Identity 1 ) } , Pair { getPair = ( Identity 'b' , Identity 2 ) } , Pair { getPair = ( Identity 'c' , Identity 0 ) } , Pair { getPair = ( Identity 'c' , Identity 1 ) } , Pair { getPair = ( Identity 'c' , Identity 2 ) } ]>>>
apportion $ fmap ZipList cols
ZipList { getZipList = [ Pair { getPair = ( Identity 'a' , Identity 0 ) } , Pair { getPair = ( Identity 'b' , Identity 1 ) } , Pair { getPair = ( Identity 'c' , Identity 2 ) } ] }
newtype Dispose f x a Source #
If f
is a functor from Hask to Hask, then, forall (x :: k). Dispose f
x
is a functor from Hask^k to Hask
The name comes from the isomorphism Dispose f ~ Flip (Compose f) :: k -> (k
-> *) -> *
, as a pun off the latin prefixes "com-", meaning together, and
"dis-", meaning apart.
Dispose | |
|
Traversable t => Traversable i (Dispose i t x) Source # | |
Foldable t => Foldable k (Dispose k t x) Source # | |
Applicative f => Applicative k (Dispose k f x) Source # | |
Functor f => Functor k (Dispose k f x) Source # | |
Eq (f (a x)) => Eq (Dispose k f x a) Source # | |
Ord (f (a x)) => Ord (Dispose k f x a) Source # | |
Show (f (a x)) => Show (Dispose k f x a) Source # | |
data Coyoneda t u where Source #
If t
is a functor from Hask^k to Hask, then Coyoneda t
is a functor
from Hask to Hask.
It's very similar to the Coyoneda
from the kan-extensions
package,
differing only in kind, and Coyoneda t a
is isomorphic to t (Const a)
for any Functor
.
Functor (Coyoneda k t) Source # | |
Applicative k t => Applicative (Coyoneda k t) Source # | |
Foldable k t => Foldable (Coyoneda k t) Source # | |
Traversable k t => Traversable (Coyoneda k t) Source # | |
getCoyoneda :: Functor t => Coyoneda t a -> t (Const a) Source #
convert a functor from its Coyoneda
representation
newtype Product f g a Source #
The product of two continuation kind functors is a continuation kind functor.
>>>
data A z where A :: Int -> [x] -> [y] -> A '(x,y)
>>>
data B z where B :: [(x,y)] -> B '(x,y)
>>>
foo = Product . Pure . Compose . Pure . Curry $ A 0 "abc" [True, False]
>>>
:t foo
foo :: Product (Pure Char) (Pure Bool) A>>>
a2b :: A z -> B z ; a2b (A _ xs ys) = B $ zip xs ys
>>>
:t fmap a2b foo
fmap a2b foo :: Product (Pure Char) (Pure Bool) B
Product | |
|
(Traversable i f, Traversable j g) => Traversable (i, j) (Product j i f g) Source # | |
(Foldable i f, Foldable j g) => Foldable (i, j) (Product j i f g) Source # | |
(Applicative i f, Applicative j g) => Applicative (i, j) (Product j i f g) Source # | |
(Functor i f, Functor j g) => Functor (i, j) (Product j i f g) Source # | |
Eq (f (Compose i (j -> *) g (Curry i j a))) => Eq (Product j i f g a) Source # | |
Ord (f (Compose i (j -> *) g (Curry i j a))) => Ord (Product j i f g a) Source # | |
Show (f (Compose i (j -> *) g (Curry i j a))) => Show (Product j i f g a) Source # | |
toProduct :: (Functor f, Functor g) => (forall x y. a x y -> b '(x, y)) -> f (Compose g a) -> Product f g b Source #
helper to make a Product
when the inner type is already curried.
>>>
comma = Pure . Compose . Pure $ ('a', True)
>>>
:t comma
comma :: Pure Char (Compose (Pure Bool) (,))>>>
:t toProduct UncurryStrict comma
toProduct UncurryStrict comma :: Product (Pure Char) (Pure Bool) (Uncurry (,))
fromProduct :: (Functor f, Functor g) => (forall x y. b '(x, y) -> a x y) -> Product f g b -> f (Compose g a) Source #
helper to unwrap a Product
when the inner type is already curried.
>>>
comma' = toProduct UncurryStrict . Pure . Compose . Pure $ ('a', True)
>>>
:t comma'
comma' :: Product (Pure Char) (Pure Bool) (Uncurry (,))>>>
:t getProduct comma'
getProduct comma' :: Pure Char (Compose (Pure Bool) (Curry (Uncurry (,))))>>>
:t fromProduct getUncurryStrict comma'
fromProduct getUncurryStrict comma' :: Pure Char (Compose (Pure Bool) (,))
newtype Coproduct f g a Source #
The coproduct of two continuation kind functors is a continuation kind functor.
>>>
data A z where { AL :: i -> A ('Left i) ; AR :: j -> A ('Right j) }
>>>
data B z where { BL :: i -> i -> B ('Left i) ; BR :: B ('Right j) }
>>>
bar = Coproduct (Pure . Compose $ AL True, Pure . Compose $ AR 'a')
>>>
:t bar
bar :: Coproduct (Pure Bool) (Pure Char) A>>>
a2b :: A z -> B z ; a2b (AL i) = BL i i ; a2b (AR _) = BR
>>>
:t fmap a2b bar
fmap a2b bar :: Coproduct (Pure Bool) (Pure Char) B
(Traversable i f, Traversable j g) => Traversable (Either i j) (Coproduct j i f g) Source # | |
(Foldable i f, Foldable j g) => Foldable (Either i j) (Coproduct j i f g) Source # | |
(Applicative i f, Applicative j g) => Applicative (Either i j) (Coproduct j i f g) Source # | |
(Functor i f, Functor j g) => Functor (Either i j) (Coproduct j i f g) Source # | |
(Eq (f (Compose i (Either i j) a (Left i j))), Eq (g (Compose j (Either i j) a (Right i j)))) => Eq (Coproduct j i f g a) Source # | |
(Ord (f (Compose i (Either i j) a (Left i j))), Ord (g (Compose j (Either i j) a (Right i j)))) => Ord (Coproduct j i f g a) Source # | |
(Show (f (Compose i (Either i j) a (Left i j))), Show (g (Compose j (Either i j) a (Right i j)))) => Show (Coproduct j i f g a) Source # | |
A continuation kind functor for pairs.
>>>
:t Pair (Identity True, Identity 'a')
Pair (Identity True, Identity 'a') :: Pair Bool Char Identity
Traversable i (Pair i x0 x1) Source # | |
Foldable k (Pair k x0 x1) Source # | |
Applicative k (Pair k x0 x1) Source # | |
Functor k (Pair k x0 x1) Source # | |
(Eq (a x1), Eq (a x0)) => Eq (Pair k x0 x1 a) Source # | |
(Ord (a x1), Ord (a x0)) => Ord (Pair k x0 x1 a) Source # | |
(Show (a x1), Show (a x0)) => Show (Pair k x0 x1 a) Source # | |
data Tuple xs a where Source #
A continuation kind functor for tuples of arbitrary length.
>>>
:t Identity True `Cons` Identity 'a' `Cons` Nil
Identity True `Cons` Identity 'a' `Cons` Nil :: Tuple '[Bool, Char] Identity
Traversable i (Tuple i xs) Source # | |
Foldable k (Tuple k xs) Source # | |
Applicative k (Tuple k xs) => Applicative k (Tuple k ((:) k x xs)) Source # | |
Applicative k (Tuple k ([] k)) Source # | |
Functor k (Tuple k xs) Source # | |
(Eq (a x), Eq (Tuple k xs a)) => Eq (Tuple k ((:) k x xs) a) Source # | |
Eq (Tuple k ([] k) a) Source # | |
(Ord (a x), Ord (Tuple k xs a)) => Ord (Tuple k ((:) k x xs) a) Source # | |
Ord (Tuple k ([] k) a) Source # | |
(Show (a x), Show (Tuple k xs a)) => Show (Tuple k ((:) k x xs) a) Source # | |
Show (Tuple k ([] k) a) Source # | |
data Tagged xs a where Source #
A continuation kind functor for tagged unions
>>>
:t [ Here (Identity True), There $ Here (Identity 'a') ]
[ Here (Identity True), There $ Here (Identity 'a') ] :: [Tagged (Bool : Char : xs) Identity]
Traversable i (Tagged i xs) Source # | |
Foldable k (Tagged k xs) Source # | |
Functor k (Tagged k xs) Source # | |
(Eq (a x), Eq (Tagged k xs a)) => Eq (Tagged k ((:) k x xs) a) Source # | |
Eq (Tagged k ([] k) a) Source # | |
(Ord (a x), Ord (Tagged k xs a)) => Ord (Tagged k ((:) k x xs) a) Source # | |
Ord (Tagged k ([] k) a) Source # | |
(Show (a x), Show (Tagged k xs a)) => Show (Tagged k ((:) k x xs) a) Source # | |
Show (Tagged k ([] k) a) Source # | |
a type-level version of flip
, it's used in the definition of
traverse
and sequenceA
as a way to reverse the order in which parameters
are passed.
Flip (Flip a)
is isomorphic to Identity a
>>>
:t Flip . Flip
Flip . Flip :: a y x -> Flip (Flip a) y x>>>
:t getFlip . getFlip
getFlip . getFlip :: Flip (Flip a) x y -> a x y
a type-level version of curry
, it's used to convert between
types of kind (i,j) -> *
and types of kind i -> j -> *
A type-level version of uncurry
, it's used to convert between
types of kind i -> j -> *
and types of kind (i,j) -> *
.
UncurryLazy | The
It is slightly finnicky, and doesn't work well with function composition
(i.e.
|
|
pattern UncurryStrict :: forall k k1 a x y. a x y -> Uncurry k k1 a ((,) k1 k x y) Source #
The UncurryStrict
pattern is useful when you need to construct/destruct
an 'Uncurry a '(x,y)' value
>>>
:t UncurryStrict . getUncurryStrict
UncurryStrict . getUncurryStrict :: Uncurry a '(x, y) -> Uncurry a '(x, y)>>>
import Data.Tuple (swap)
>>>
:t UncurryStrict . Flip . swap . getUncurryStrict
UncurryStrict . Flip . swap . getUncurryStrict :: Uncurry (,) '(x, y) -> Uncurry (Flip (,)) '(x, y)
It works well with function composition and requires fewer hints, but cannot
be used to construct or match values of type Uncurry a z
, such as are
needed by fmap
.
>>>
:t (\(UncurryLazy axy) -> UncurryStrict axy) :: Uncurry a z -> Uncurry a z
<interactive>:1:38: error: • Couldn't match type ‘z1’ with ‘'(x0, y0)’ ... • In the first argument of ‘UncurryStrict’, namely ‘axy’ ...>>>
:t (\(UncurryStrict axy) -> UncurryLazy axy) :: Uncurry a z -> Uncurry a z
<interactive>:1:4: error: • Couldn't match type ‘z1’ with ‘'(x0, y0)’ ... • In the pattern: UncurryStrict axy ...
However, it is very useful when paired with toProduct
.
getUncurryStrict :: Uncurry a '(x, y) -> a x y Source #
a pseudo-record accessor, corresponding to matching the UncurryStrict
pattern. Can be useful when paired with fromProduct
uncurried :: (forall x y. a x y -> b x y) -> Uncurry a z -> Uncurry b z Source #
a helper for lifting functions on curried types to functions
on their uncurried equivalents. Very useful when using the Functor
instance for Product
s.
>>>
comma' = toProduct UncurryStrict . Pure . Compose . Pure $ ('a', True)
>>>
:t comma'
comma' :: Product (Pure Char) (Pure Bool) (Uncurry (,))>>>
:t uncurried (const . snd) <$> comma'
uncurried (const . snd) <$> comma' :: Product (Pure Char) (Pure Bool) (Uncurry (->))