Implement Sieve and Cosieve profunctors
This commit is contained in:
parent
ff82a24001
commit
b5d5526550
|
@ -1,5 +1,7 @@
|
||||||
module Data.Profunctor.Sieve
|
module Data.Profunctor.Sieve
|
||||||
|
|
||||||
|
import Control.Monad.Identity
|
||||||
|
import Data.Morphisms
|
||||||
import Data.Profunctor
|
import Data.Profunctor
|
||||||
|
|
||||||
%default total
|
%default total
|
||||||
|
@ -10,6 +12,36 @@ interface (Profunctor p, Functor f) => Sieve p f | p where
|
||||||
sieve : p a b -> a -> f b
|
sieve : p a b -> a -> f b
|
||||||
|
|
||||||
|
|
||||||
|
export
|
||||||
|
Sieve Morphism Identity where
|
||||||
|
sieve (Mor f) = Id . f
|
||||||
|
|
||||||
|
export
|
||||||
|
[Function] Sieve (\a,b => a -> b) Identity using Profunctor.Function where
|
||||||
|
sieve = (Id .)
|
||||||
|
|
||||||
|
export
|
||||||
|
Functor f => Sieve (Kleislimorphism f) f where
|
||||||
|
sieve = applyKleisli
|
||||||
|
|
||||||
|
export
|
||||||
|
Functor f => Sieve (Star f) f where
|
||||||
|
sieve = applyStar
|
||||||
|
|
||||||
|
|
||||||
public export
|
public export
|
||||||
interface (Profunctor p, Functor f) => Cosieve p f | p where
|
interface (Profunctor p, Functor f) => Cosieve p f | p where
|
||||||
cosieve : p a b -> f a -> b
|
cosieve : p a b -> f a -> b
|
||||||
|
|
||||||
|
export
|
||||||
|
Cosieve Morphism Identity where
|
||||||
|
cosieve (Mor f) = f . runIdentity
|
||||||
|
|
||||||
|
namespace Cosieve
|
||||||
|
export
|
||||||
|
[Function] Cosieve (\a,b => a -> b) Identity using Profunctor.Function where
|
||||||
|
cosieve = (. runIdentity)
|
||||||
|
|
||||||
|
export
|
||||||
|
Functor f => Cosieve (Costar f) f where
|
||||||
|
cosieve = applyCostar
|
||||||
|
|
Loading…
Reference in a new issue