class (Functor f) <= Alt f where
(<|>) :: forall a. f a -> f a -> f aThe 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.
class (Applicative f, Plus f) <= Alternative f whereThe 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 :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a]many :: forall f a. (Alternative f, Lazy1 f) => f a -> f [a](<*) :: forall a b f. (Apply f) => f a -> f b -> f a(*>) :: forall a b f. (Apply f) => f a -> f b -> f blift2 :: forall a b c f. (Apply f) => (a -> b -> c) -> f a -> f b -> f clift3 :: forall a b c d f. (Apply f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f dlift4 :: forall a b c d e f. (Apply f) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f elift5 :: 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 gforever :: forall a b f. (Apply f) => f a -> f b(=<<) :: 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 cjoin :: forall a m. (Bind m) => m (m a) -> m aifM :: forall a m. (Bind m) => m Boolean -> m a -> m a -> m aclass (Extend w) <= Comonad w where
extract :: forall a. w a -> aclass (Functor w) <= Extend w where
(<<=) :: forall b a. (w a -> b) -> w a -> w binstance 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 -> cduplicate :: forall a w. (Extend w) => w a -> w (w a)(<$) :: forall f a b. (Functor f) => a -> f b -> f a($>) :: forall f a b. (Functor f) => f a -> b -> f bclass Lazy l where
defer :: (Unit -> l) -> lclass Lazy1 l where
defer1 :: forall a. (Unit -> l a) -> l aclass Lazy2 l where
defer2 :: forall a b. (Unit -> l a b) -> l a bfix :: forall l a. (Lazy l) => (l -> l) -> lfix1 :: forall l a. (Lazy1 l) => (l a -> l a) -> l afix2 :: forall l a b. (Lazy2 l) => (l a b -> l a b) -> l a breplicateM :: forall m a. (Monad m) => Number -> m a -> m [a]foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> [b] -> m awhen :: forall m. (Monad m) => Boolean -> m Unit -> m Unitunless :: forall m. (Monad m) => Boolean -> m Unit -> m UnitfilterM :: 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])class (Monad m, Alternative m) <= MonadPlus m whereThe 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 :: forall m. (MonadPlus m) => Boolean -> m Unitclass (Alt f) <= Plus f where
empty :: forall a. f aThe 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