Package frege.control.Traversable

Compiled: Wed Dec 05 00:09:52 PST 2012 from source file: ./frege/control/Traversable.fr

Package Documentation

This module provide type class Traversable and instances for [] and Maybe

Table of Content

Imports

Classes

class Traversable (Foldable t, Functor t) => t

Functors representing data structures that can be traversed from left to right.

Minimal complete definition: Traversable.traverse or Traversable.sequenceA.

The superclass instances should satisfy the following:

In the Functor instance, Functor.fmap should be equivalent to traversal with the identity applicative functor (fmapDefault).

In the Foldable instance, Foldable.Foldable.foldMap should be equivalent to traversal with a constant applicative functor (foldMapDefault).

Note that the functions Traversable.mapM, Traversable.sequence, forM are just specialized versions of Traversable.traverse, Traversable.sequenceA and for, and wouldn't be required in Frege. They are included for Haskell compatibility only. In Haskell the specialized functions are needed as Haskell monads are no Applicatives.

Known Instances

[], Identity.Identity, Maybe

Member Functions

mapM :: (Traversable t, Monad m) => (a->m b) -> t a -> m (t b)

Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. This function exists for Haskell compatibility only.

sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)

Evaluate each monadic action in the structure from left to right, and collect the results. This function exists for Haskell compatibility only.

sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)

Evaluate each action in the structure from left to right, and collect the results.

traverse :: (Traversable t, Applicative f) => (a->f b) -> t a -> f (t b)

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Instances

instance Applicative StateL s

Member Functions

*> :: StateL β γ -> StateL β α -> StateL β α

inherited from Applicative.*>

<* :: StateL β γ -> StateL β α -> StateL β γ

inherited from Applicative.<*

<*> :: StateL β (γ->α) -> StateL β γ -> StateL β α
return :: α -> StateL β α
instance Applicative StateR s

Member Functions

*> :: StateR β γ -> StateR β α -> StateR β α

inherited from Applicative.*>

<* :: StateR β γ -> StateR β α -> StateR β γ

inherited from Applicative.<*

<*> :: StateR β (γ->α) -> StateR β γ -> StateR β α
return :: α -> StateR β α
instance Functor StateL s

Member Functions

fmap :: (γ->α) -> StateL β γ -> StateL β α
instance Functor StateR s

Member Functions

fmap :: (γ->α) -> StateR β γ -> StateR β α
instance Traversable Identity

Member Functions

mapM :: Monad β => (γ->β α) -> Identity γ -> β (Identity α)

inherited from Traversable.mapM

sequence :: Monad α => Identity (α β) -> α (Identity β)

inherited from Traversable.sequence

sequenceA :: Applicative α => Identity (α β) -> α (Identity β)

inherited from Traversable.sequenceA

traverse :: Applicative β => (γ->β α) -> Identity γ -> β (Identity α)
instance Traversable Maybe

Member Functions

mapM :: Monad β => (γ->β α) -> Maybe γ -> β (Maybe α)

inherited from Traversable.mapM

sequence :: Monad α => Maybe (α β) -> α (Maybe β)

inherited from Traversable.sequence

sequenceA :: Applicative α => Maybe (α β) -> α (Maybe β)

inherited from Traversable.sequenceA

traverse :: Applicative β => (γ->β α) -> Maybe γ -> β (Maybe α)
instance Traversable []

Member Functions

mapM :: Monad β => (γ->β α) -> [γ] -> β [α]
sequence :: Monad α => [α β] -> α [β]

inherited from Traversable.sequence

sequenceA :: Applicative α => [α β] -> α [β]

inherited from Traversable.sequenceA

traverse :: Applicative β => (γ->β α) -> [γ] -> β [α]

Data Types

data StateL s a

Constructors

StateL {run :: s -> (s, a)}

Member Functions

run :: StateL α β -> α -> (α, β)

access field run

data StateR s a

Constructors

StateR {run :: s -> (s, a)}

Member Functions

run :: StateR α β -> α -> (α, β)

access field run

Functions and Values

fmapDefault :: Traversable t => (a->b) -> t a -> t b

This function may be used as a value for `fmap` in a `Functor` instance, provided that Traversable.traverse is defined. (Using fmapDefault with a Traversable instance defined only by Traversable.sequenceA will result in infinite recursion.)

foldMapDefault :: (Traversable t, Monoid m) => (a->m) -> t a -> m

This function may be used as a value for `Data.Foldable.foldMap` in a `Foldable` instance.

for :: (Traversable t, Applicative f) => t a -> (a->f b) -> f (t b)

for is Traversable.traverse with its arguments flipped.

forM :: (Traversable t, Monad m) => t a -> (a->m b) -> m (t b)

forM is Traversable.mapM with its arguments flipped.

This function exists for Haskell compatibility only.

mapAccumL :: Traversable t => (a->b->(a, c)) -> a -> t b -> (a, t c)

The mapAccumL function behaves like a combination of Functor.fmap and Foldable.Foldable.foldl; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.

mapAccumR :: Traversable t => (a->b->(a, c)) -> a -> t b -> (a, t c)

The mapAccumR function behaves like a combination of Functor.fmap and Foldable.Foldable.foldr; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.

mapMa :: (Traversable t, Monad m) => (a->m b) -> t a -> m (t b)

Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. This function exists for Haskell compatibility only.

sequenceAa :: (Traversable t, Applicative f) => t (f a) -> f (t a)

Evaluate each action in the structure from left to right, and collect the results.

sequencea :: (Traversable t, Monad m) => t (m a) -> m (t a)

Evaluate each monadic action in the structure from left to right, and collect the results. This function exists for Haskell compatibility only.

traversea :: (Traversable t, Applicative f) => (a->f b) -> t a -> f (t b)

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Functions and Values by Type

α -> Bool

StateL.has$run, StateR.has$run

(s -> (s, a)) -> StateL s a

StateL.StateL

(s -> (s, a)) -> StateR s a

StateR.StateR

StateL α β -> α -> (α, β)

StateL.run

StateR α β -> α -> (α, β)

StateR.run

α -> StateL β α

Applicative_StateL.return

α -> StateR β α

Applicative_StateR.return

Applicative α => Identity (α β) -> α (Identity β)

Traversable_Identity.sequenceA

Applicative α => Maybe (α β) -> α (Maybe β)

Traversable_Maybe.sequenceA

Applicative α => [α β] -> α [β]

Traversable_[].sequenceA

Monad α => Identity (α β) -> α (Identity β)

Traversable_Identity.sequence

Monad α => Maybe (α β) -> α (Maybe β)

Traversable_Maybe.sequence

Monad α => [α β] -> α [β]

Traversable_[].sequence

StateL β (γ->α) -> StateL β γ -> StateL β α

Applicative_StateL.<*>

StateL β γ -> StateL β α -> StateL β α

Applicative_StateL.*>

StateL β γ -> StateL β α -> StateL β γ

Applicative_StateL.<*

StateR β (γ->α) -> StateR β γ -> StateR β α

Applicative_StateR.<*>

StateR β γ -> StateR β α -> StateR β α

Applicative_StateR.*>

StateR β γ -> StateR β α -> StateR β γ

Applicative_StateR.<*

(γ->α) -> StateL β γ -> StateL β α

Functor_StateL.fmap

(γ->α) -> StateR β γ -> StateR β α

Functor_StateR.fmap

Traversable t => (a->b) -> t a -> t b

fmapDefault

(Traversable t, Monoid m) => (a->m) -> t a -> m

foldMapDefault

(Traversable t, Applicative f) => t (f a) -> f (t a)

sequenceAa, Traversable.sequenceA

(Traversable t, Monad m) => t (m a) -> m (t a)

sequencea, Traversable.sequence

Applicative β => (γ->β α) -> Identity γ -> β (Identity α)

Traversable_Identity.traverse

Applicative β => (γ->β α) -> Maybe γ -> β (Maybe α)

Traversable_Maybe.traverse

Applicative β => (γ->β α) -> [γ] -> β [α]

Traversable_[].traverse

Monad β => (γ->β α) -> Identity γ -> β (Identity α)

Traversable_Identity.mapM

Monad β => (γ->β α) -> Maybe γ -> β (Maybe α)

Traversable_Maybe.mapM

Monad β => (γ->β α) -> [γ] -> β [α]

Traversable_[].mapM

StateL β α -> (-> β (β, α)->γ->(γ, δ)) -> StateL γ δ

StateL.chg$run

StateL β α -> (γ->(γ, δ)) -> StateL γ δ

StateL.upd$run

StateR β α -> (-> β (β, α)->γ->(γ, δ)) -> StateR γ δ

StateR.chg$run

StateR β α -> (γ->(γ, δ)) -> StateR γ δ

StateR.upd$run

Traversable t => (a->b->(a, c)) -> a -> t b -> (a, t c)

mapAccumL, mapAccumR

(Traversable t, Applicative f) => (a->f b) -> t a -> f (t b)

traversea, Traversable.traverse

(Traversable t, Applicative f) => t a -> (a->f b) -> f (t b)

for

(Traversable t, Monad m) => (a->m b) -> t a -> m (t b)

mapMa, Traversable.mapM

(Traversable t, Monad m) => t a -> (a->m b) -> m (t b)

forM

Valid HTML 4.01 Strict