folds-0.7.3: Beautiful Folding

Copyright(C) 2009-2013 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Data.Fold

Contents

Description

 

Synopsis

Scaners and Foldings

class Choice p => Scan p where Source #

Minimal complete definition

interspersing

Methods

prefix1 :: a -> p a b -> p a b Source #

prefix1 :: Folding p => a -> p a b -> p a b Source #

postfix1 :: p a b -> a -> p a b Source #

postfix1 :: Folding p => p a b -> a -> p a b Source #

run1 :: a -> p a b -> b Source #

Apply a Folding to a single element of input

run1 :: Folding p => a -> p a b -> b Source #

Apply a Folding to a single element of input

interspersing :: a -> p a b -> p a b Source #

Instances

Scan L Source # 

Methods

prefix1 :: a -> L a b -> L a b Source #

postfix1 :: L a b -> a -> L a b Source #

run1 :: a -> L a b -> b Source #

interspersing :: a -> L a b -> L a b Source #

Scan L' Source # 

Methods

prefix1 :: a -> L' a b -> L' a b Source #

postfix1 :: L' a b -> a -> L' a b Source #

run1 :: a -> L' a b -> b Source #

interspersing :: a -> L' a b -> L' a b Source #

Scan L1 Source # 

Methods

prefix1 :: a -> L1 a b -> L1 a b Source #

postfix1 :: L1 a b -> a -> L1 a b Source #

run1 :: a -> L1 a b -> b Source #

interspersing :: a -> L1 a b -> L1 a b Source #

Scan L1' Source # 

Methods

prefix1 :: a -> L1' a b -> L1' a b Source #

postfix1 :: L1' a b -> a -> L1' a b Source #

run1 :: a -> L1' a b -> b Source #

interspersing :: a -> L1' a b -> L1' a b Source #

Scan M Source # 

Methods

prefix1 :: a -> M a b -> M a b Source #

postfix1 :: M a b -> a -> M a b Source #

run1 :: a -> M a b -> b Source #

interspersing :: a -> M a b -> M a b Source #

Scan M1 Source # 

Methods

prefix1 :: a -> M1 a b -> M1 a b Source #

postfix1 :: M1 a b -> a -> M1 a b Source #

run1 :: a -> M1 a b -> b Source #

interspersing :: a -> M1 a b -> M1 a b Source #

Scan R Source # 

Methods

prefix1 :: a -> R a b -> R a b Source #

postfix1 :: R a b -> a -> R a b Source #

run1 :: a -> R a b -> b Source #

interspersing :: a -> R a b -> R a b Source #

Scan R1 Source # 

Methods

prefix1 :: a -> R1 a b -> R1 a b Source #

postfix1 :: R1 a b -> a -> R1 a b Source #

run1 :: a -> R1 a b -> b Source #

interspersing :: a -> R1 a b -> R1 a b Source #

class Scan p => Folding p where Source #

Minimal complete definition

prefixOf, postfixOf, runOf, filtering

Methods

prefix :: Foldable t => t a -> p a b -> p a b Source #

Partially apply a Folding to some initial input on the left.

prefixOf :: Fold s a -> s -> p a b -> p a b Source #

postfix :: Foldable t => p a b -> t a -> p a b Source #

postfixOf :: Fold s a -> p a b -> s -> p a b Source #

run :: Foldable t => t a -> p a b -> b Source #

Apply a Folding to a container full of input:

>>> run ["hello","world"] $ L id (++) []
"helloworld"
>>> run [1,2,3] $ L id (+) 0
6

runOf :: Fold s a -> s -> p a b -> b Source #

filtering :: (a -> Bool) -> p a b -> p a b Source #

Instances

Folding L Source #

efficient prefix, leaky postfix

Methods

prefix :: Foldable t => t a -> L a b -> L a b Source #

prefixOf :: Fold s a -> s -> L a b -> L a b Source #

postfix :: Foldable t => L a b -> t a -> L a b Source #

postfixOf :: Fold s a -> L a b -> s -> L a b Source #

run :: Foldable t => t a -> L a b -> b Source #

runOf :: Fold s a -> s -> L a b -> b Source #

filtering :: (a -> Bool) -> L a b -> L a b Source #

Folding L' Source #

efficient prefix, leaky postfix

Methods

prefix :: Foldable t => t a -> L' a b -> L' a b Source #

prefixOf :: Fold s a -> s -> L' a b -> L' a b Source #

postfix :: Foldable t => L' a b -> t a -> L' a b Source #

postfixOf :: Fold s a -> L' a b -> s -> L' a b Source #

run :: Foldable t => t a -> L' a b -> b Source #

runOf :: Fold s a -> s -> L' a b -> b Source #

filtering :: (a -> Bool) -> L' a b -> L' a b Source #

Folding M Source #

efficient prefix, efficient postfix

Methods

prefix :: Foldable t => t a -> M a b -> M a b Source #

prefixOf :: Fold s a -> s -> M a b -> M a b Source #

postfix :: Foldable t => M a b -> t a -> M a b Source #

postfixOf :: Fold s a -> M a b -> s -> M a b Source #

run :: Foldable t => t a -> M a b -> b Source #

runOf :: Fold s a -> s -> M a b -> b Source #

filtering :: (a -> Bool) -> M a b -> M a b Source #

Folding R Source #

leaky prefix, efficient postfix

Methods

prefix :: Foldable t => t a -> R a b -> R a b Source #

prefixOf :: Fold s a -> s -> R a b -> R a b Source #

postfix :: Foldable t => R a b -> t a -> R a b Source #

postfixOf :: Fold s a -> R a b -> s -> R a b Source #

run :: Foldable t => t a -> R a b -> b Source #

runOf :: Fold s a -> s -> R a b -> b Source #

filtering :: (a -> Bool) -> R a b -> R a b Source #

Combinators

beneath :: Profunctor p => Optic p Identity s t a b -> p a b -> p s t Source #

Lift a Folding into a Prism.

This acts like a generalized notion of "costrength", when applied to a Folding, causing it to return the left-most value that fails to match the Prism, or the result of accumulating rewrapped in the Prism if everything matches.

>>> run [Left 1, Left 2, Left 3] $ beneath _Left $ R id (+) 0
Left 6
>>> run [Left 1, Right 2, Right 3] $ beneath _Left $ R id (+) 0
Right 2
beneath :: Prism s t a b -> p a b -> p s t
beneath :: Iso s t a b   -> p a b -> p s t

Scans

Left Scans

data L1 a b Source #

A Mealy Machine

Constructors

L1 (c -> b) (c -> a -> c) (a -> c) 

Instances

Arrow L1 Source # 

Methods

arr :: (b -> c) -> L1 b c #

first :: L1 b c -> L1 (b, d) (c, d) #

second :: L1 b c -> L1 (d, b) (d, c) #

(***) :: L1 b c -> L1 b' c' -> L1 (b, b') (c, c') #

(&&&) :: L1 b c -> L1 b c' -> L1 b (c, c') #

ArrowChoice L1 Source # 

Methods

left :: L1 b c -> L1 (Either b d) (Either c d) #

right :: L1 b c -> L1 (Either d b) (Either d c) #

(+++) :: L1 b c -> L1 b' c' -> L1 (Either b b') (Either c c') #

(|||) :: L1 b d -> L1 c d -> L1 (Either b c) d #

Corepresentable L1 Source # 

Associated Types

type Corep (L1 :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep L1 d -> c) -> L1 d c #

Profunctor L1 Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> L1 b c -> L1 a d #

lmap :: (a -> b) -> L1 b c -> L1 a c #

rmap :: (b -> c) -> L1 a b -> L1 a c #

(#.) :: Coercible * c b => (b -> c) -> L1 a b -> L1 a c #

(.#) :: Coercible * b a => L1 b c -> (a -> b) -> L1 a c #

Choice L1 Source # 

Methods

left' :: L1 a b -> L1 (Either a c) (Either b c) #

right' :: L1 a b -> L1 (Either c a) (Either c b) #

Closed L1 Source # 

Methods

closed :: L1 a b -> L1 (x -> a) (x -> b) #

Strong L1 Source # 

Methods

first' :: L1 a b -> L1 (a, c) (b, c) #

second' :: L1 a b -> L1 (c, a) (c, b) #

Costrong L1 Source # 

Methods

unfirst :: L1 (a, d) (b, d) -> L1 a b #

unsecond :: L1 (d, a) (d, b) -> L1 a b #

Scan L1 Source # 

Methods

prefix1 :: a -> L1 a b -> L1 a b Source #

postfix1 :: L1 a b -> a -> L1 a b Source #

run1 :: a -> L1 a b -> b Source #

interspersing :: a -> L1 a b -> L1 a b Source #

AsL1' L1 Source # 

Methods

asL1' :: L1 a b -> L1' a b Source #

AsRM1 L1 Source # 

Methods

asM1 :: L1 a b -> M1 a b Source #

asR1 :: L1 a b -> R1 a b Source #

Cosieve L1 NonEmpty Source # 

Methods

cosieve :: L1 a b -> NonEmpty a -> b #

Monad (L1 a) Source # 

Methods

(>>=) :: L1 a a -> (a -> L1 a b) -> L1 a b #

(>>) :: L1 a a -> L1 a b -> L1 a b #

return :: a -> L1 a a #

fail :: String -> L1 a a #

Functor (L1 a) Source # 

Methods

fmap :: (a -> b) -> L1 a a -> L1 a b #

(<$) :: a -> L1 a b -> L1 a a #

MonadFix (L1 a) Source # 

Methods

mfix :: (a -> L1 a a) -> L1 a a #

Applicative (L1 a) Source # 

Methods

pure :: a -> L1 a a #

(<*>) :: L1 a (a -> b) -> L1 a a -> L1 a b #

(*>) :: L1 a a -> L1 a b -> L1 a b #

(<*) :: L1 a a -> L1 a b -> L1 a a #

Distributive (L1 a) Source # 

Methods

distribute :: Functor f => f (L1 a a) -> L1 a (f a) #

collect :: Functor f => (a -> L1 a b) -> f a -> L1 a (f b) #

distributeM :: Monad m => m (L1 a a) -> L1 a (m a) #

collectM :: Monad m => (a -> L1 a b) -> m a -> L1 a (m b) #

Representable (L1 a) Source # 

Associated Types

type Rep (L1 a :: * -> *) :: * #

Methods

tabulate :: (Rep (L1 a) -> a) -> L1 a a #

index :: L1 a a -> Rep (L1 a) -> a #

MonadZip (L1 a) Source # 

Methods

mzip :: L1 a a -> L1 a b -> L1 a (a, b) #

mzipWith :: (a -> b -> c) -> L1 a a -> L1 a b -> L1 a c #

munzip :: L1 a (a, b) -> (L1 a a, L1 a b) #

Pointed (L1 a) Source # 

Methods

point :: a -> L1 a a #

Apply (L1 a) Source # 

Methods

(<.>) :: L1 a (a -> b) -> L1 a a -> L1 a b #

(.>) :: L1 a a -> L1 a b -> L1 a b #

(<.) :: L1 a a -> L1 a b -> L1 a a #

Category * L1 Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

Semigroupoid * L1 Source # 

Methods

o :: c j k1 -> c i j -> c i k1 #

MonadReader (NonEmpty a) (L1 a) Source # 

Methods

ask :: L1 a (NonEmpty a) #

local :: (NonEmpty a -> NonEmpty a) -> L1 a a -> L1 a a #

reader :: (NonEmpty a -> a) -> L1 a a #

type Corep L1 Source # 
type Rep (L1 a) Source # 
type Rep (L1 a) = NonEmpty a

data L1' a b Source #

A strict Mealy Machine

Constructors

L1' (c -> b) (c -> a -> c) (a -> c) 

Instances

Arrow L1' Source # 

Methods

arr :: (b -> c) -> L1' b c #

first :: L1' b c -> L1' (b, d) (c, d) #

second :: L1' b c -> L1' (d, b) (d, c) #

(***) :: L1' b c -> L1' b' c' -> L1' (b, b') (c, c') #

(&&&) :: L1' b c -> L1' b c' -> L1' b (c, c') #

ArrowChoice L1' Source # 

Methods

left :: L1' b c -> L1' (Either b d) (Either c d) #

right :: L1' b c -> L1' (Either d b) (Either d c) #

(+++) :: L1' b c -> L1' b' c' -> L1' (Either b b') (Either c c') #

(|||) :: L1' b d -> L1' c d -> L1' (Either b c) d #

Corepresentable L1' Source # 

Associated Types

type Corep (L1' :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep L1' d -> c) -> L1' d c #

Profunctor L1' Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> L1' b c -> L1' a d #

lmap :: (a -> b) -> L1' b c -> L1' a c #

rmap :: (b -> c) -> L1' a b -> L1' a c #

(#.) :: Coercible * c b => (b -> c) -> L1' a b -> L1' a c #

(.#) :: Coercible * b a => L1' b c -> (a -> b) -> L1' a c #

Choice L1' Source # 

Methods

left' :: L1' a b -> L1' (Either a c) (Either b c) #

right' :: L1' a b -> L1' (Either c a) (Either c b) #

Closed L1' Source # 

Methods

closed :: L1' a b -> L1' (x -> a) (x -> b) #

Strong L1' Source # 

Methods

first' :: L1' a b -> L1' (a, c) (b, c) #

second' :: L1' a b -> L1' (c, a) (c, b) #

Costrong L1' Source # 

Methods

unfirst :: L1' (a, d) (b, d) -> L1' a b #

unsecond :: L1' (d, a) (d, b) -> L1' a b #

Scan L1' Source # 

Methods

prefix1 :: a -> L1' a b -> L1' a b Source #

postfix1 :: L1' a b -> a -> L1' a b Source #

run1 :: a -> L1' a b -> b Source #

interspersing :: a -> L1' a b -> L1' a b Source #

AsL1' L1' Source # 

Methods

asL1' :: L1' a b -> L1' a b Source #

AsRM1 L1' Source # 

Methods

asM1 :: L1' a b -> M1 a b Source #

asR1 :: L1' a b -> R1 a b Source #

Cosieve L1' NonEmpty Source # 

Methods

cosieve :: L1' a b -> NonEmpty a -> b #

Monad (L1' a) Source # 

Methods

(>>=) :: L1' a a -> (a -> L1' a b) -> L1' a b #

(>>) :: L1' a a -> L1' a b -> L1' a b #

return :: a -> L1' a a #

fail :: String -> L1' a a #

Functor (L1' a) Source # 

Methods

fmap :: (a -> b) -> L1' a a -> L1' a b #

(<$) :: a -> L1' a b -> L1' a a #

MonadFix (L1' a) Source # 

Methods

mfix :: (a -> L1' a a) -> L1' a a #

Applicative (L1' a) Source # 

Methods

pure :: a -> L1' a a #

(<*>) :: L1' a (a -> b) -> L1' a a -> L1' a b #

(*>) :: L1' a a -> L1' a b -> L1' a b #

(<*) :: L1' a a -> L1' a b -> L1' a a #

Distributive (L1' a) Source # 

Methods

distribute :: Functor f => f (L1' a a) -> L1' a (f a) #

collect :: Functor f => (a -> L1' a b) -> f a -> L1' a (f b) #

distributeM :: Monad m => m (L1' a a) -> L1' a (m a) #

collectM :: Monad m => (a -> L1' a b) -> m a -> L1' a (m b) #

Representable (L1' a) Source # 

Associated Types

type Rep (L1' a :: * -> *) :: * #

Methods

tabulate :: (Rep (L1' a) -> a) -> L1' a a #

index :: L1' a a -> Rep (L1' a) -> a #

Pointed (L1' a) Source # 

Methods

point :: a -> L1' a a #

Apply (L1' a) Source # 

Methods

(<.>) :: L1' a (a -> b) -> L1' a a -> L1' a b #

(.>) :: L1' a a -> L1' a b -> L1' a b #

(<.) :: L1' a a -> L1' a b -> L1' a a #

Category * L1' Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

Semigroupoid * L1' Source # 

Methods

o :: c j k1 -> c i j -> c i k1 #

MonadReader (NonEmpty a) (L1' a) Source # 

Methods

ask :: L1' a (NonEmpty a) #

local :: (NonEmpty a -> NonEmpty a) -> L1' a a -> L1' a a #

reader :: (NonEmpty a -> a) -> L1' a a #

type Corep L1' Source # 
type Rep (L1' a) Source # 
type Rep (L1' a) = NonEmpty a

Semigroup Scans

data M1 a b Source #

A semigroup reducer

Constructors

M1 (m -> b) (a -> m) (m -> m -> m) 

Instances

Arrow M1 Source # 

Methods

arr :: (b -> c) -> M1 b c #

first :: M1 b c -> M1 (b, d) (c, d) #

second :: M1 b c -> M1 (d, b) (d, c) #

(***) :: M1 b c -> M1 b' c' -> M1 (b, b') (c, c') #

(&&&) :: M1 b c -> M1 b c' -> M1 b (c, c') #

ArrowChoice M1 Source # 

Methods

left :: M1 b c -> M1 (Either b d) (Either c d) #

right :: M1 b c -> M1 (Either d b) (Either d c) #

(+++) :: M1 b c -> M1 b' c' -> M1 (Either b b') (Either c c') #

(|||) :: M1 b d -> M1 c d -> M1 (Either b c) d #

Corepresentable M1 Source # 

Associated Types

type Corep (M1 :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep M1 d -> c) -> M1 d c #

Profunctor M1 Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> M1 b c -> M1 a d #

lmap :: (a -> b) -> M1 b c -> M1 a c #

rmap :: (b -> c) -> M1 a b -> M1 a c #

(#.) :: Coercible * c b => (b -> c) -> M1 a b -> M1 a c #

(.#) :: Coercible * b a => M1 b c -> (a -> b) -> M1 a c #

Choice M1 Source # 

Methods

left' :: M1 a b -> M1 (Either a c) (Either b c) #

right' :: M1 a b -> M1 (Either c a) (Either c b) #

Closed M1 Source # 

Methods

closed :: M1 a b -> M1 (x -> a) (x -> b) #

Strong M1 Source # 

Methods

first' :: M1 a b -> M1 (a, c) (b, c) #

second' :: M1 a b -> M1 (c, a) (c, b) #

Costrong M1 Source # 

Methods

unfirst :: M1 (a, d) (b, d) -> M1 a b #

unsecond :: M1 (d, a) (d, b) -> M1 a b #

Scan M1 Source # 

Methods

prefix1 :: a -> M1 a b -> M1 a b Source #

postfix1 :: M1 a b -> a -> M1 a b Source #

run1 :: a -> M1 a b -> b Source #

interspersing :: a -> M1 a b -> M1 a b Source #

AsRM1 M1 Source # 

Methods

asM1 :: M1 a b -> M1 a b Source #

asR1 :: M1 a b -> R1 a b Source #

Cosieve M1 FreeSemigroup Source # 

Methods

cosieve :: M1 a b -> FreeSemigroup a -> b #

Monad (M1 a) Source # 

Methods

(>>=) :: M1 a a -> (a -> M1 a b) -> M1 a b #

(>>) :: M1 a a -> M1 a b -> M1 a b #

return :: a -> M1 a a #

fail :: String -> M1 a a #

Functor (M1 a) Source # 

Methods

fmap :: (a -> b) -> M1 a a -> M1 a b #

(<$) :: a -> M1 a b -> M1 a a #

MonadFix (M1 a) Source # 

Methods

mfix :: (a -> M1 a a) -> M1 a a #

Applicative (M1 a) Source # 

Methods

pure :: a -> M1 a a #

(<*>) :: M1 a (a -> b) -> M1 a a -> M1 a b #

(*>) :: M1 a a -> M1 a b -> M1 a b #

(<*) :: M1 a a -> M1 a b -> M1 a a #

Distributive (M1 a) Source # 

Methods

distribute :: Functor f => f (M1 a a) -> M1 a (f a) #

collect :: Functor f => (a -> M1 a b) -> f a -> M1 a (f b) #

distributeM :: Monad m => m (M1 a a) -> M1 a (m a) #

collectM :: Monad m => (a -> M1 a b) -> m a -> M1 a (m b) #

Representable (M1 a) Source # 

Associated Types

type Rep (M1 a :: * -> *) :: * #

Methods

tabulate :: (Rep (M1 a) -> a) -> M1 a a #

index :: M1 a a -> Rep (M1 a) -> a #

MonadZip (M1 a) Source # 

Methods

mzip :: M1 a a -> M1 a b -> M1 a (a, b) #

mzipWith :: (a -> b -> c) -> M1 a a -> M1 a b -> M1 a c #

munzip :: M1 a (a, b) -> (M1 a a, M1 a b) #

Pointed (M1 a) Source # 

Methods

point :: a -> M1 a a #

Apply (M1 a) Source # 

Methods

(<.>) :: M1 a (a -> b) -> M1 a a -> M1 a b #

(.>) :: M1 a a -> M1 a b -> M1 a b #

(<.) :: M1 a a -> M1 a b -> M1 a a #

Category * M1 Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

Semigroupoid * M1 Source # 

Methods

o :: c j k1 -> c i j -> c i k1 #

MonadReader (FreeSemigroup a) (M1 a) Source # 

Methods

ask :: M1 a (FreeSemigroup a) #

local :: (FreeSemigroup a -> FreeSemigroup a) -> M1 a a -> M1 a a #

reader :: (FreeSemigroup a -> a) -> M1 a a #

type Corep M1 Source # 
type Rep (M1 a) Source # 
type Rep (M1 a) = FreeSemigroup a

Right Scans

data R1 a b Source #

A reversed Mealy machine

Constructors

R1 (c -> b) (a -> c -> c) (a -> c) 

Instances

Arrow R1 Source # 

Methods

arr :: (b -> c) -> R1 b c #

first :: R1 b c -> R1 (b, d) (c, d) #

second :: R1 b c -> R1 (d, b) (d, c) #

(***) :: R1 b c -> R1 b' c' -> R1 (b, b') (c, c') #

(&&&) :: R1 b c -> R1 b c' -> R1 b (c, c') #

ArrowChoice R1 Source # 

Methods

left :: R1 b c -> R1 (Either b d) (Either c d) #

right :: R1 b c -> R1 (Either d b) (Either d c) #

(+++) :: R1 b c -> R1 b' c' -> R1 (Either b b') (Either c c') #

(|||) :: R1 b d -> R1 c d -> R1 (Either b c) d #

Corepresentable R1 Source # 

Associated Types

type Corep (R1 :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep R1 d -> c) -> R1 d c #

Profunctor R1 Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> R1 b c -> R1 a d #

lmap :: (a -> b) -> R1 b c -> R1 a c #

rmap :: (b -> c) -> R1 a b -> R1 a c #

(#.) :: Coercible * c b => (b -> c) -> R1 a b -> R1 a c #

(.#) :: Coercible * b a => R1 b c -> (a -> b) -> R1 a c #

Choice R1 Source # 

Methods

left' :: R1 a b -> R1 (Either a c) (Either b c) #

right' :: R1 a b -> R1 (Either c a) (Either c b) #

Closed R1 Source # 

Methods

closed :: R1 a b -> R1 (x -> a) (x -> b) #

Strong R1 Source # 

Methods

first' :: R1 a b -> R1 (a, c) (b, c) #

second' :: R1 a b -> R1 (c, a) (c, b) #

Costrong R1 Source # 

Methods

unfirst :: R1 (a, d) (b, d) -> R1 a b #

unsecond :: R1 (d, a) (d, b) -> R1 a b #

Scan R1 Source # 

Methods

prefix1 :: a -> R1 a b -> R1 a b Source #

postfix1 :: R1 a b -> a -> R1 a b Source #

run1 :: a -> R1 a b -> b Source #

interspersing :: a -> R1 a b -> R1 a b Source #

AsRM1 R1 Source # 

Methods

asM1 :: R1 a b -> M1 a b Source #

asR1 :: R1 a b -> R1 a b Source #

Cosieve R1 NonEmpty Source # 

Methods

cosieve :: R1 a b -> NonEmpty a -> b #

Monad (R1 a) Source # 

Methods

(>>=) :: R1 a a -> (a -> R1 a b) -> R1 a b #

(>>) :: R1 a a -> R1 a b -> R1 a b #

return :: a -> R1 a a #

fail :: String -> R1 a a #

Functor (R1 a) Source # 

Methods

fmap :: (a -> b) -> R1 a a -> R1 a b #

(<$) :: a -> R1 a b -> R1 a a #

MonadFix (R1 a) Source # 

Methods

mfix :: (a -> R1 a a) -> R1 a a #

Applicative (R1 a) Source # 

Methods

pure :: a -> R1 a a #

(<*>) :: R1 a (a -> b) -> R1 a a -> R1 a b #

(*>) :: R1 a a -> R1 a b -> R1 a b #

(<*) :: R1 a a -> R1 a b -> R1 a a #

Distributive (R1 a) Source # 

Methods

distribute :: Functor f => f (R1 a a) -> R1 a (f a) #

collect :: Functor f => (a -> R1 a b) -> f a -> R1 a (f b) #

distributeM :: Monad m => m (R1 a a) -> R1 a (m a) #

collectM :: Monad m => (a -> R1 a b) -> m a -> R1 a (m b) #

Representable (R1 a) Source # 

Associated Types

type Rep (R1 a :: * -> *) :: * #

Methods

tabulate :: (Rep (R1 a) -> a) -> R1 a a #

index :: R1 a a -> Rep (R1 a) -> a #

MonadZip (R1 a) Source # 

Methods

mzip :: R1 a a -> R1 a b -> R1 a (a, b) #

mzipWith :: (a -> b -> c) -> R1 a a -> R1 a b -> R1 a c #

munzip :: R1 a (a, b) -> (R1 a a, R1 a b) #

Pointed (R1 a) Source # 

Methods

point :: a -> R1 a a #

Apply (R1 a) Source # 

Methods

(<.>) :: R1 a (a -> b) -> R1 a a -> R1 a b #

(.>) :: R1 a a -> R1 a b -> R1 a b #

(<.) :: R1 a a -> R1 a b -> R1 a a #

Category * R1 Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

Semigroupoid * R1 Source # 

Methods

o :: c j k1 -> c i j -> c i k1 #

MonadReader (NonEmpty a) (R1 a) Source # 

Methods

ask :: R1 a (NonEmpty a) #

local :: (NonEmpty a -> NonEmpty a) -> R1 a a -> R1 a a #

reader :: (NonEmpty a -> a) -> R1 a a #

type Corep R1 Source # 
type Rep (R1 a) Source # 
type Rep (R1 a) = NonEmpty a

Foldings

Left Foldings

data L a b Source #

A Moore Machine

Constructors

L (r -> b) (r -> a -> r) r 

Instances

Corepresentable L Source # 

Associated Types

type Corep (L :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep L d -> c) -> L d c #

Profunctor L Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> L b c -> L a d #

lmap :: (a -> b) -> L b c -> L a c #

rmap :: (b -> c) -> L a b -> L a c #

(#.) :: Coercible * c b => (b -> c) -> L a b -> L a c #

(.#) :: Coercible * b a => L b c -> (a -> b) -> L a c #

Choice L Source # 

Methods

left' :: L a b -> L (Either a c) (Either b c) #

right' :: L a b -> L (Either c a) (Either c b) #

Closed L Source # 

Methods

closed :: L a b -> L (x -> a) (x -> b) #

Costrong L Source # 

Methods

unfirst :: L (a, d) (b, d) -> L a b #

unsecond :: L (d, a) (d, b) -> L a b #

Folding L Source #

efficient prefix, leaky postfix

Methods

prefix :: Foldable t => t a -> L a b -> L a b Source #

prefixOf :: Fold s a -> s -> L a b -> L a b Source #

postfix :: Foldable t => L a b -> t a -> L a b Source #

postfixOf :: Fold s a -> L a b -> s -> L a b Source #

run :: Foldable t => t a -> L a b -> b Source #

runOf :: Fold s a -> s -> L a b -> b Source #

filtering :: (a -> Bool) -> L a b -> L a b Source #

Scan L Source # 

Methods

prefix1 :: a -> L a b -> L a b Source #

postfix1 :: L a b -> a -> L a b Source #

run1 :: a -> L a b -> b Source #

interspersing :: a -> L a b -> L a b Source #

AsL' L Source #

We can convert from a lazy left folding to a strict left folding.

Methods

asL' :: L a b -> L' a b Source #

AsL1' L Source # 

Methods

asL1' :: L a b -> L1' a b Source #

AsRM L Source #

We can convert from a lazy left folding to a right or monoidal fold

Methods

asM :: L a b -> M a b Source #

asR :: L a b -> R a b Source #

AsRM1 L Source # 

Methods

asM1 :: L a b -> M1 a b Source #

asR1 :: L a b -> R1 a b Source #

Cosieve L [] Source #
>>> cosieve (L id (+) 0) [1,2,3]
6

Methods

cosieve :: L a b -> [a] -> b #

Monad (L a) Source # 

Methods

(>>=) :: L a a -> (a -> L a b) -> L a b #

(>>) :: L a a -> L a b -> L a b #

return :: a -> L a a #

fail :: String -> L a a #

Functor (L a) Source # 

Methods

fmap :: (a -> b) -> L a a -> L a b #

(<$) :: a -> L a b -> L a a #

MonadFix (L a) Source # 

Methods

mfix :: (a -> L a a) -> L a a #

Applicative (L a) Source # 

Methods

pure :: a -> L a a #

(<*>) :: L a (a -> b) -> L a a -> L a b #

(*>) :: L a a -> L a b -> L a b #

(<*) :: L a a -> L a b -> L a a #

Distributive (L a) Source # 

Methods

distribute :: Functor f => f (L a a) -> L a (f a) #

collect :: Functor f => (a -> L a b) -> f a -> L a (f b) #

distributeM :: Monad m => m (L a a) -> L a (m a) #

collectM :: Monad m => (a -> L a b) -> m a -> L a (m b) #

Representable (L a) Source # 

Associated Types

type Rep (L a :: * -> *) :: * #

Methods

tabulate :: (Rep (L a) -> a) -> L a a #

index :: L a a -> Rep (L a) -> a #

MonadZip (L a) Source # 

Methods

mzip :: L a a -> L a b -> L a (a, b) #

mzipWith :: (a -> b -> c) -> L a a -> L a b -> L a c #

munzip :: L a (a, b) -> (L a a, L a b) #

Comonad (L a) Source # 

Methods

extract :: L a a -> a #

duplicate :: L a a -> L a (L a a) #

extend :: (L a a -> b) -> L a a -> L a b #

ComonadApply (L a) Source # 

Methods

(<@>) :: L a (a -> b) -> L a a -> L a b #

(@>) :: L a a -> L a b -> L a b #

(<@) :: L a a -> L a b -> L a a #

Apply (L a) Source # 

Methods

(<.>) :: L a (a -> b) -> L a a -> L a b #

(.>) :: L a a -> L a b -> L a b #

(<.) :: L a a -> L a b -> L a a #

Bind (L a) Source # 

Methods

(>>-) :: L a a -> (a -> L a b) -> L a b #

join :: L a (L a a) -> L a a #

Extend (L a) Source # 

Methods

duplicated :: L a a -> L a (L a a) #

extended :: (L a a -> b) -> L a a -> L a b #

MonadReader [a] (L a) Source # 

Methods

ask :: L a [a] #

local :: ([a] -> [a]) -> L a a -> L a a #

reader :: ([a] -> a) -> L a a #

type Corep L Source # 
type Corep L = []
type Rep (L a) Source # 
type Rep (L a) = [a]

data L' a b Source #

A strict left fold / strict Moore machine

Constructors

L' (r -> b) (r -> a -> r) r 

Instances

Corepresentable L' Source # 

Associated Types

type Corep (L' :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep L' d -> c) -> L' d c #

Profunctor L' Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> L' b c -> L' a d #

lmap :: (a -> b) -> L' b c -> L' a c #

rmap :: (b -> c) -> L' a b -> L' a c #

(#.) :: Coercible * c b => (b -> c) -> L' a b -> L' a c #

(.#) :: Coercible * b a => L' b c -> (a -> b) -> L' a c #

Choice L' Source # 

Methods

left' :: L' a b -> L' (Either a c) (Either b c) #

right' :: L' a b -> L' (Either c a) (Either c b) #

Closed L' Source # 

Methods

closed :: L' a b -> L' (x -> a) (x -> b) #

Costrong L' Source # 

Methods

unfirst :: L' (a, d) (b, d) -> L' a b #

unsecond :: L' (d, a) (d, b) -> L' a b #

Folding L' Source #

efficient prefix, leaky postfix

Methods

prefix :: Foldable t => t a -> L' a b -> L' a b Source #

prefixOf :: Fold s a -> s -> L' a b -> L' a b Source #

postfix :: Foldable t => L' a b -> t a -> L' a b Source #

postfixOf :: Fold s a -> L' a b -> s -> L' a b Source #

run :: Foldable t => t a -> L' a b -> b Source #

runOf :: Fold s a -> s -> L' a b -> b Source #

filtering :: (a -> Bool) -> L' a b -> L' a b Source #

Scan L' Source # 

Methods

prefix1 :: a -> L' a b -> L' a b Source #

postfix1 :: L' a b -> a -> L' a b Source #

run1 :: a -> L' a b -> b Source #

interspersing :: a -> L' a b -> L' a b Source #

AsL' L' Source #

We can convert a lazy fold to itself

Methods

asL' :: L' a b -> L' a b Source #

AsL1' L' Source # 

Methods

asL1' :: L' a b -> L1' a b Source #

AsRM L' Source #

We can convert from a strict left folding to a right or monoidal fold

Methods

asM :: L' a b -> M a b Source #

asR :: L' a b -> R a b Source #

AsRM1 L' Source # 

Methods

asM1 :: L' a b -> M1 a b Source #

asR1 :: L' a b -> R1 a b Source #

Cosieve L' [] Source # 

Methods

cosieve :: L' a b -> [a] -> b #

Monad (L' a) Source # 

Methods

(>>=) :: L' a a -> (a -> L' a b) -> L' a b #

(>>) :: L' a a -> L' a b -> L' a b #

return :: a -> L' a a #

fail :: String -> L' a a #

Functor (L' a) Source # 

Methods

fmap :: (a -> b) -> L' a a -> L' a b #

(<$) :: a -> L' a b -> L' a a #

MonadFix (L' a) Source # 

Methods

mfix :: (a -> L' a a) -> L' a a #

Applicative (L' a) Source # 

Methods

pure :: a -> L' a a #

(<*>) :: L' a (a -> b) -> L' a a -> L' a b #

(*>) :: L' a a -> L' a b -> L' a b #

(<*) :: L' a a -> L' a b -> L' a a #

Distributive (L' a) Source # 

Methods

distribute :: Functor f => f (L' a a) -> L' a (f a) #

collect :: Functor f => (a -> L' a b) -> f a -> L' a (f b) #

distributeM :: Monad m => m (L' a a) -> L' a (m a) #

collectM :: Monad m => (a -> L' a b) -> m a -> L' a (m b) #

Representable (L' a) Source # 

Associated Types

type Rep (L' a :: * -> *) :: * #

Methods

tabulate :: (Rep (L' a) -> a) -> L' a a #

index :: L' a a -> Rep (L' a) -> a #

MonadZip (L' a) Source # 

Methods

mzip :: L' a a -> L' a b -> L' a (a, b) #

mzipWith :: (a -> b -> c) -> L' a a -> L' a b -> L' a c #

munzip :: L' a (a, b) -> (L' a a, L' a b) #

Comonad (L' a) Source # 

Methods

extract :: L' a a -> a #

duplicate :: L' a a -> L' a (L' a a) #

extend :: (L' a a -> b) -> L' a a -> L' a b #

ComonadApply (L' a) Source # 

Methods

(<@>) :: L' a (a -> b) -> L' a a -> L' a b #

(@>) :: L' a a -> L' a b -> L' a b #

(<@) :: L' a a -> L' a b -> L' a a #

Apply (L' a) Source # 

Methods

(<.>) :: L' a (a -> b) -> L' a a -> L' a b #

(.>) :: L' a a -> L' a b -> L' a b #

(<.) :: L' a a -> L' a b -> L' a a #

Bind (L' a) Source # 

Methods

(>>-) :: L' a a -> (a -> L' a b) -> L' a b #

join :: L' a (L' a a) -> L' a a #

Extend (L' a) Source # 

Methods

duplicated :: L' a a -> L' a (L' a a) #

extended :: (L' a a -> b) -> L' a a -> L' a b #

MonadReader [a] (L' a) Source # 

Methods

ask :: L' a [a] #

local :: ([a] -> [a]) -> L' a a -> L' a a #

reader :: ([a] -> a) -> L' a a #

type Corep L' Source # 
type Corep L' = []
type Rep (L' a) Source # 
type Rep (L' a) = [a]

Monoidal Foldings

data M a b Source #

A foldMap caught in amber. a.k.a. a monoidal reducer

Constructors

M (m -> b) (a -> m) (m -> m -> m) m 

Instances

Corepresentable M Source # 

Associated Types

type Corep (M :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep M d -> c) -> M d c #

Profunctor M Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> M b c -> M a d #

lmap :: (a -> b) -> M b c -> M a c #

rmap :: (b -> c) -> M a b -> M a c #

(#.) :: Coercible * c b => (b -> c) -> M a b -> M a c #

(.#) :: Coercible * b a => M b c -> (a -> b) -> M a c #

Choice M Source # 

Methods

left' :: M a b -> M (Either a c) (Either b c) #

right' :: M a b -> M (Either c a) (Either c b) #

Closed M Source # 

Methods

closed :: M a b -> M (x -> a) (x -> b) #

Costrong M Source # 

Methods

unfirst :: M (a, d) (b, d) -> M a b #

unsecond :: M (d, a) (d, b) -> M a b #

Folding M Source #

efficient prefix, efficient postfix

Methods

prefix :: Foldable t => t a -> M a b -> M a b Source #

prefixOf :: Fold s a -> s -> M a b -> M a b Source #

postfix :: Foldable t => M a b -> t a -> M a b Source #

postfixOf :: Fold s a -> M a b -> s -> M a b Source #

run :: Foldable t => t a -> M a b -> b Source #

runOf :: Fold s a -> s -> M a b -> b Source #

filtering :: (a -> Bool) -> M a b -> M a b Source #

Scan M Source # 

Methods

prefix1 :: a -> M a b -> M a b Source #

postfix1 :: M a b -> a -> M a b Source #

run1 :: a -> M a b -> b Source #

interspersing :: a -> M a b -> M a b Source #

AsRM M Source #

We can convert from a monoidal fold to a lazy right fold

Methods

asM :: M a b -> M a b Source #

asR :: M a b -> R a b Source #

AsRM1 M Source # 

Methods

asM1 :: M a b -> M1 a b Source #

asR1 :: M a b -> R1 a b Source #

Cosieve M FreeMonoid Source # 

Methods

cosieve :: M a b -> FreeMonoid a -> b #

Monad (M a) Source # 

Methods

(>>=) :: M a a -> (a -> M a b) -> M a b #

(>>) :: M a a -> M a b -> M a b #

return :: a -> M a a #

fail :: String -> M a a #

Functor (M a) Source # 

Methods

fmap :: (a -> b) -> M a a -> M a b #

(<$) :: a -> M a b -> M a a #

MonadFix (M a) Source # 

Methods

mfix :: (a -> M a a) -> M a a #

Applicative (M a) Source # 

Methods

pure :: a -> M a a #

(<*>) :: M a (a -> b) -> M a a -> M a b #

(*>) :: M a a -> M a b -> M a b #

(<*) :: M a a -> M a b -> M a a #

Distributive (M a) Source # 

Methods

distribute :: Functor f => f (M a a) -> M a (f a) #

collect :: Functor f => (a -> M a b) -> f a -> M a (f b) #

distributeM :: Monad m => m (M a a) -> M a (m a) #

collectM :: Monad m => (a -> M a b) -> m a -> M a (m b) #

Representable (M a) Source # 

Associated Types

type Rep (M a :: * -> *) :: * #

Methods

tabulate :: (Rep (M a) -> a) -> M a a #

index :: M a a -> Rep (M a) -> a #

MonadZip (M a) Source # 

Methods

mzip :: M a a -> M a b -> M a (a, b) #

mzipWith :: (a -> b -> c) -> M a a -> M a b -> M a c #

munzip :: M a (a, b) -> (M a a, M a b) #

Comonad (M a) Source # 

Methods

extract :: M a a -> a #

duplicate :: M a a -> M a (M a a) #

extend :: (M a a -> b) -> M a a -> M a b #

ComonadApply (M a) Source # 

Methods

(<@>) :: M a (a -> b) -> M a a -> M a b #

(@>) :: M a a -> M a b -> M a b #

(<@) :: M a a -> M a b -> M a a #

Apply (M a) Source # 

Methods

(<.>) :: M a (a -> b) -> M a a -> M a b #

(.>) :: M a a -> M a b -> M a b #

(<.) :: M a a -> M a b -> M a a #

Bind (M a) Source # 

Methods

(>>-) :: M a a -> (a -> M a b) -> M a b #

join :: M a (M a a) -> M a a #

Extend (M a) Source # 

Methods

duplicated :: M a a -> M a (M a a) #

extended :: (M a a -> b) -> M a a -> M a b #

MonadReader (FreeMonoid a) (M a) Source # 

Methods

ask :: M a (FreeMonoid a) #

local :: (FreeMonoid a -> FreeMonoid a) -> M a a -> M a a #

reader :: (FreeMonoid a -> a) -> M a a #

type Corep M Source # 
type Rep (M a) Source # 
type Rep (M a) = FreeMonoid a

Right Foldings

data R a b Source #

right folds / a reversed Moore machine

Constructors

R (r -> b) (a -> r -> r) r 

Instances

Corepresentable R Source # 

Associated Types

type Corep (R :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep R d -> c) -> R d c #

Profunctor R Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> R b c -> R a d #

lmap :: (a -> b) -> R b c -> R a c #

rmap :: (b -> c) -> R a b -> R a c #

(#.) :: Coercible * c b => (b -> c) -> R a b -> R a c #

(.#) :: Coercible * b a => R b c -> (a -> b) -> R a c #

Choice R Source # 

Methods

left' :: R a b -> R (Either a c) (Either b c) #

right' :: R a b -> R (Either c a) (Either c b) #

Closed R Source # 

Methods

closed :: R a b -> R (x -> a) (x -> b) #

Costrong R Source # 

Methods

unfirst :: R (a, d) (b, d) -> R a b #

unsecond :: R (d, a) (d, b) -> R a b #

Folding R Source #

leaky prefix, efficient postfix

Methods

prefix :: Foldable t => t a -> R a b -> R a b Source #

prefixOf :: Fold s a -> s -> R a b -> R a b Source #

postfix :: Foldable t => R a b -> t a -> R a b Source #

postfixOf :: Fold s a -> R a b -> s -> R a b Source #

run :: Foldable t => t a -> R a b -> b Source #

runOf :: Fold s a -> s -> R a b -> b Source #

filtering :: (a -> Bool) -> R a b -> R a b Source #

Scan R Source # 

Methods

prefix1 :: a -> R a b -> R a b Source #

postfix1 :: R a b -> a -> R a b Source #

run1 :: a -> R a b -> b Source #

interspersing :: a -> R a b -> R a b Source #

AsRM R Source #

We can convert from a lazy right fold to a monoidal fold

Methods

asM :: R a b -> M a b Source #

asR :: R a b -> R a b Source #

AsRM1 R Source # 

Methods

asM1 :: R a b -> M1 a b Source #

asR1 :: R a b -> R1 a b Source #

Cosieve R [] Source # 

Methods

cosieve :: R a b -> [a] -> b #

Monad (R a) Source # 

Methods

(>>=) :: R a a -> (a -> R a b) -> R a b #

(>>) :: R a a -> R a b -> R a b #

return :: a -> R a a #

fail :: String -> R a a #

Functor (R a) Source # 

Methods

fmap :: (a -> b) -> R a a -> R a b #

(<$) :: a -> R a b -> R a a #

MonadFix (R a) Source # 

Methods

mfix :: (a -> R a a) -> R a a #

Applicative (R a) Source # 

Methods

pure :: a -> R a a #

(<*>) :: R a (a -> b) -> R a a -> R a b #

(*>) :: R a a -> R a b -> R a b #

(<*) :: R a a -> R a b -> R a a #

Distributive (R a) Source # 

Methods

distribute :: Functor f => f (R a a) -> R a (f a) #

collect :: Functor f => (a -> R a b) -> f a -> R a (f b) #

distributeM :: Monad m => m (R a a) -> R a (m a) #

collectM :: Monad m => (a -> R a b) -> m a -> R a (m b) #

Representable (R a) Source # 

Associated Types

type Rep (R a :: * -> *) :: * #

Methods

tabulate :: (Rep (R a) -> a) -> R a a #

index :: R a a -> Rep (R a) -> a #

MonadZip (R a) Source # 

Methods

mzip :: R a a -> R a b -> R a (a, b) #

mzipWith :: (a -> b -> c) -> R a a -> R a b -> R a c #

munzip :: R a (a, b) -> (R a a, R a b) #

Comonad (R a) Source # 

Methods

extract :: R a a -> a #

duplicate :: R a a -> R a (R a a) #

extend :: (R a a -> b) -> R a a -> R a b #

ComonadApply (R a) Source # 

Methods

(<@>) :: R a (a -> b) -> R a a -> R a b #

(@>) :: R a a -> R a b -> R a b #

(<@) :: R a a -> R a b -> R a a #

Apply (R a) Source # 

Methods

(<.>) :: R a (a -> b) -> R a a -> R a b #

(.>) :: R a a -> R a b -> R a b #

(<.) :: R a a -> R a b -> R a a #

Bind (R a) Source # 

Methods

(>>-) :: R a a -> (a -> R a b) -> R a b #

join :: R a (R a a) -> R a a #

Extend (R a) Source # 

Methods

duplicated :: R a a -> R a (R a a) #

extended :: (R a a -> b) -> R a a -> R a b #

MonadReader [a] (R a) Source # 

Methods

ask :: R a [a] #

local :: ([a] -> [a]) -> R a a -> R a a #

reader :: ([a] -> a) -> R a a #

type Corep R Source # 
type Corep R = []
type Rep (R a) Source # 
type Rep (R a) = [a]

Homomorphisms

Scan Homomorphisms

We define f to be a scan homomorphism between p and q when:

f :: forall a b. p a b -> q a b
run1 xs (f φ)        ≡ run1 xs φ
prefix1 xs (f φ)     ≡ f (prefix1 xs φ)
postfix1 (f φ) xs    ≡ f (postfix1 φ xs)
dimap l r (f φ)      ≡ f (dimap l r φ)
pure a               ≡ f (pure a)
f φ <*> f ψ          ≡ f (φ <*> ψ)
return a             ≡ f (return a)
f φ >>= f . k        ≡ f (φ >>= k)
interspersing a (f φ) ≡ f (interspersing a φ)

Furthermore,

left' (f φ) and f (left' φ) should agree whenever either answer is Right

right' (f φ) and f (right' φ) should agree whenever either answer is Left

class AsRM1 p where Source #

Methods

asM1 :: p a b -> M1 a b Source #

asM1 is a scan homomorphism to a semigroup reducer

asR1 :: p a b -> R1 a b Source #

asM1 is a scan homomorphism to a right scan

Instances

AsRM1 L Source # 

Methods

asM1 :: L a b -> M1 a b Source #

asR1 :: L a b -> R1 a b Source #

AsRM1 L' Source # 

Methods

asM1 :: L' a b -> M1 a b Source #

asR1 :: L' a b -> R1 a b Source #

AsRM1 L1 Source # 

Methods

asM1 :: L1 a b -> M1 a b Source #

asR1 :: L1 a b -> R1 a b Source #

AsRM1 L1' Source # 

Methods

asM1 :: L1' a b -> M1 a b Source #

asR1 :: L1' a b -> R1 a b Source #

AsRM1 M Source # 

Methods

asM1 :: M a b -> M1 a b Source #

asR1 :: M a b -> R1 a b Source #

AsRM1 M1 Source # 

Methods

asM1 :: M1 a b -> M1 a b Source #

asR1 :: M1 a b -> R1 a b Source #

AsRM1 R Source # 

Methods

asM1 :: R a b -> M1 a b Source #

asR1 :: R a b -> R1 a b Source #

AsRM1 R1 Source # 

Methods

asM1 :: R1 a b -> M1 a b Source #

asR1 :: R1 a b -> R1 a b Source #

class AsRM1 p => AsL1' p where Source #

Methods

asL1' :: p a b -> L1' a b Source #

Scan homomorphism to a strict Mealy machine

asL1' :: AsL' p => p a b -> L1' a b Source #

Scan homomorphism to a strict Mealy machine

Instances

AsL1' L Source # 

Methods

asL1' :: L a b -> L1' a b Source #

AsL1' L' Source # 

Methods

asL1' :: L' a b -> L1' a b Source #

AsL1' L1 Source # 

Methods

asL1' :: L1 a b -> L1' a b Source #

AsL1' L1' Source # 

Methods

asL1' :: L1' a b -> L1' a b Source #

Folding Homomorphisms

We define f to be a folding homomorphism between p and q when f is a scan homomorphism and additionally we can satisfy:

run xs (f φ)         ≡ run xs φ
runOf l xs (f φ)     ≡ runOf l xs φ
prefix xs (f φ)      ≡ f (prefix xs φ)
prefixOf l xs (f φ)  ≡ f (prefixOf l xs φ)
postfix (f φ) xs     ≡ f (postfix φ xs)
postfixOf l (f φ) xs ≡ f (postfixOf l φ xs)
extract (f φ)        ≡ extract φ
filtering p (f φ)     ≡ f (filtering p φ)

Note: A law including extend is explicitly excluded. To work consistenly across foldings, use prefix and postfix instead.

class AsRM1 p => AsRM p where Source #

Methods

asM :: p a b -> M a b Source #

asM is a folding homomorphism to a monoidal folding

run xs (asM φ)         ≡ run xs φ
prefix xs (asM φ)      ≡ asM (prefix xs φ)
prefixOf l xs (asM φ)  ≡ asM (prefixOf l xs φ)
postfix (asM φ) xs     ≡ asM (postfix φ xs)
postfixOf l (asM φ) xs ≡ asM (postfixOf l φ xs)
left' (asM φ)          ≡ asM (left' φ)
right' (asM φ)         ≡ asM (right' φ)
dimap l r (asM φ)      ≡ asM (dimap l r φ)
extract (asM φ)        ≡ extract φ
pure a                  ≡ asM (pure a)
asM φ <*> asM ψ        ≡ asM<*> ψ)
return a                ≡ asM (return a)
asM φ >>= asM . k      ≡ asM>>= k)
filtering p (asM φ)     ≡ asM (filtering p φ)
interspersing a (asM φ) ≡ asM (interspersing a φ)

asR :: p a b -> R a b Source #

asR is a folding homomorphism to a right folding

run xs (asR φ)         ≡ run xs φ
prefix xs (asR φ)      ≡ asR (prefix xs φ)
prefixOf l xs (asR φ)  ≡ asR (prefixOf l xs φ)
postfix (asR φ) xs     ≡ asR (postfix φ xs)
postfixOf l (asR φ) xs ≡ asR (postfixOf l φ xs)
left' (asR φ)          ≡ asR (left' φ)
right' (asR φ)         ≡ asR (right' φ)
dimap l r (asR φ)      ≡ asR (dimap l r φ)
extract (asR φ)        ≡ extract φ
pure a                  ≡ asR (pure a)
asR φ <*> asR ψ        ≡ asR<*> ψ)
return a                ≡ asR (return a)
asR φ >>= asR . k      ≡ asR>>= k)
filtering p (asR φ)     ≡ asR (filtering p φ)
interspersing a (asR φ) ≡ asR (interspersing a φ)

Instances

AsRM L Source #

We can convert from a lazy left folding to a right or monoidal fold

Methods

asM :: L a b -> M a b Source #

asR :: L a b -> R a b Source #

AsRM L' Source #

We can convert from a strict left folding to a right or monoidal fold

Methods

asM :: L' a b -> M a b Source #

asR :: L' a b -> R a b Source #

AsRM M Source #

We can convert from a monoidal fold to a lazy right fold

Methods

asM :: M a b -> M a b Source #

asR :: M a b -> R a b Source #

AsRM R Source #

We can convert from a lazy right fold to a monoidal fold

Methods

asM :: R a b -> M a b Source #

asR :: R a b -> R a b Source #

class (AsRM p, AsL1' p) => AsL' p where Source #

Minimal complete definition

asL'

Methods

asL' :: p a b -> L' a b Source #

asL' is a folding homomorphism to a strict left folding

run xs (asL' φ)         ≡ run xs φ
prefix xs (asL' φ)      ≡ asL' (prefix xs φ)
prefixOf l xs (asL' φ)  ≡ asL' (prefixOf l xs φ)
postfix (asL' φ) xs     ≡ asL' (postfix φ xs)
postfixOf l (asL' φ) xs ≡ asL' (postfixOf l φ xs)
left' (asL' φ)          ≡ asL' (left' φ)
right' (asL' φ)         ≡ asL' (right' φ)
dimap l r (asL' φ)      ≡ asL' (dimap l r φ)
extract (asL' φ)        ≡ extract φ
pure a                   ≡ asL' (pure a)
asL' φ <*> asL' ψ       ≡ asL'<*> ψ)
return a                 ≡ asL' (return a)
asL' φ >>= asL' . k     ≡ asL'>>= k)
filtering p (asL' φ)     ≡ asL' (filtering p φ)
interspersing a (asL' φ) ≡ asL' (interspersing a φ)

Instances

AsL' L Source #

We can convert from a lazy left folding to a strict left folding.

Methods

asL' :: L a b -> L' a b Source #

AsL' L' Source #

We can convert a lazy fold to itself

Methods

asL' :: L' a b -> L' a b Source #