Skip to content

brainrake/purescript-control

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Module Documentation

Module Control.Alt

Alt

class (Functor f) <= Alt f where
  (<|>) :: forall a. f a -> f a -> f a

The Alt type class identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *, like Array or List, rather than concrete types String or Number.

Alt instances are required to satisfy the following laws:

  • Associativity: (x <|> y) <|> z == x <|> (y <|> z)
  • Distributivity: f <$> (x <|> y) == (f <$> x) <|> (f <$> y)

For example, the Array ([]) type is an instance of Alt, where (<|>) is defined to be concatenation.

Module Control.Alternative

Alternative

class (Applicative f, Plus f) <= Alternative f where

The Alternative type class has no members of its own; it just specifies that the type constructor has both Applicative and Plus instances.

Types which have Alternative instances should also satisfy the following laws:

  • Distributivity: (f <|> g) <*> x == (f <*> x) <|> (g <*> x)
  • Annihilation: empty <*> f = empty

some

some :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a]

many

many :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a]

Module Control.Apply

(<*)

(<*) :: forall a b f. (Apply f) => f a -> f b -> f a

(*>)

(*>) :: forall a b f. (Apply f) => f a -> f b -> f b

lift2

lift2 :: forall a b c f. (Apply f) => (a -> b -> c) -> f a -> f b -> f c

lift3

lift3 :: forall a b c d f. (Apply f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

lift4

lift4 :: forall a b c d e f. (Apply f) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e

lift5

lift5 :: forall a b c d e f g. (Apply f) => (a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g

forever

forever :: forall a b f. (Apply f) => f a -> f b

Module Control.Bind

(=<<)

(=<<) :: forall a b m. (Bind m) => (a -> m b) -> m a -> m b

(>=>)

(>=>) :: forall a b c m. (Bind m) => (a -> m b) -> (b -> m c) -> a -> m c

(<=<)

(<=<) :: forall a b c m. (Bind m) => (b -> m c) -> (a -> m b) -> a -> m c

join

join :: forall a m. (Bind m) => m (m a) -> m a

ifM

ifM :: forall a m. (Bind m) => m Boolean -> m a -> m a -> m a

Module Control.Comonad

Comonad

class (Extend w) <= Comonad w where
  extract :: forall a. w a -> a

Module Control.Extend

Extend

class (Functor w) <= Extend w where
  (<<=) :: forall b a. (w a -> b) -> w a -> w b

extendArr

instance extendArr :: (Semigroup w) => Extend (Prim.Function w)

(=>>)

(=>>) :: forall b a w. (Extend w) => w a -> (w a -> b) -> w b

(=>=)

(=>=) :: forall b a w c. (Extend w) => (w a -> b) -> (w b -> c) -> w a -> c

(=<=)

(=<=) :: forall b a w c. (Extend w) => (w b -> c) -> (w a -> b) -> w a -> c

duplicate

duplicate :: forall a w. (Extend w) => w a -> w (w a)

Module Control.Functor

(<$)

(<$) :: forall f a b. (Functor f) => a -> f b -> f a

($>)

($>) :: forall f a b. (Functor f) => f a -> b -> f b

Module Control.Lazy

Lazy

class Lazy l where
  defer :: (Unit -> l) -> l

Lazy1

class Lazy1 l where
  defer1 :: forall a. (Unit -> l a) -> l a

Lazy2

class Lazy2 l where
  defer2 :: forall a b. (Unit -> l a b) -> l a b

fix

fix :: forall l a. (Lazy l) => (l -> l) -> l

fix1

fix1 :: forall l a. (Lazy1 l) => (l a -> l a) -> l a

fix2

fix2 :: forall l a b. (Lazy2 l) => (l a b -> l a b) -> l a b

Module Control.Monad

replicateM

replicateM :: forall m a. (Monad m) => Number -> m a -> m [a]

foldM

foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> [b] -> m a

when

when :: forall m. (Monad m) => Boolean -> m Unit -> m Unit

unless

unless :: forall m. (Monad m) => Boolean -> m Unit -> m Unit

filterM

filterM :: forall a m. (Monad m) => (a -> m Boolean) -> [a] -> m [a]

Filter where the predicate returns a monadic Boolean. For example:

powerSet :: forall a. [a] -> [[a]]
powerSet = filterM (const [true, false])

Module Control.MonadPlus

MonadPlus

class (Monad m, Alternative m) <= MonadPlus m where

The MonadPlus type class has no members of its own; it just specifies that the type has both Monad and Alternative instances.

Types which have MonadPlus instances should also satisfy the following laws:

  • Distributivity: (x <|> y) >>= f == (x >>= f) <|> (y >>= f)
  • Annihilation: empty >>= f = empty

guard

guard :: forall m. (MonadPlus m) => Boolean -> m Unit

Module Control.Plus

Plus

class (Alt f) <= Plus f where
  empty :: forall a. f a

The Plus type class extends the Alt type class with a value that should be the left and right identity for (<|>). It is similar to Monoid, except that it applies to types of kind * -> *, like Array or List, rather than concrete types like String or Number.

Plus instances should satisfy the following laws:

  • Left identity: empty <|> x == x
  • Right identity: x <|> empty == x
  • Annihilation: f <$> empty == empty

About

Monad and Applicative utility functions

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PureScript 91.6%
  • JavaScript 8.4%