module Fold.Effectful.Examples.Boring
(
monoid,
null, length,
and, or, all, any,
sum, product, mean, variance, standardDeviation,
element, notElement, find, lookup,
index, findIndex, elementIndex,
list, reverseList,
magma, semigroup,
first, last,
maximum, minimum, maximumBy, minimumBy,
)
where
import Control.Monad (Monad)
import Data.Maybe (Maybe)
import Data.Ord (Ord, Ordering)
import Data.Semigroup (Semigroup)
import Fold.Effectful.Type (EffectfulFold)
import Data.Bool (Bool)
import Data.Eq (Eq)
import Data.Monoid (Monoid)
import Numeric.Natural (Natural)
import Prelude (Floating, Fractional, Num)
import qualified Fold.Pure.Examples.Interesting as Pure
import qualified Fold.Nonempty.Examples.Interesting as Nonempty
import qualified Fold.Shortcut.Examples.Interesting as Shortcut
import qualified Fold.ShortcutNonempty.Examples.Interesting as ShortcutNonempty
import qualified Fold.Effectful.Conversion as Convert
magma :: (a -> a -> a) -> Monad m => EffectfulFold m a (Maybe a)
magma :: forall a (m :: * -> *).
(a -> a -> a) -> Monad m => EffectfulFold m a (Maybe a)
magma a -> a -> a
step = forall (m :: * -> *) a b.
Monad m =>
NonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.nonemptyFold (forall a. (a -> a -> a) -> NonemptyFold a a
Nonempty.magma a -> a -> a
step)
semigroup :: Semigroup a => Monad m => EffectfulFold m a (Maybe a)
semigroup :: forall a (m :: * -> *).
(Semigroup a, Monad m) =>
EffectfulFold m a (Maybe a)
semigroup = forall (m :: * -> *) a b.
Monad m =>
NonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.nonemptyFold forall a. Semigroup a => NonemptyFold a a
Nonempty.semigroup
first :: Monad m => EffectfulFold m a (Maybe a)
first :: forall (m :: * -> *) a. Monad m => EffectfulFold m a (Maybe a)
first = forall (m :: * -> *) a b.
Monad m =>
ShortcutNonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.shortcutNonemptyFold forall a. ShortcutNonemptyFold a a
ShortcutNonempty.first
last :: Monad m => EffectfulFold m a (Maybe a)
last :: forall (m :: * -> *) a. Monad m => EffectfulFold m a (Maybe a)
last = forall (m :: * -> *) a b.
Monad m =>
NonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.nonemptyFold forall a. NonemptyFold a a
Nonempty.last
maximum :: Ord a => Monad m => EffectfulFold m a (Maybe a)
maximum :: forall a (m :: * -> *).
(Ord a, Monad m) =>
EffectfulFold m a (Maybe a)
maximum = forall (m :: * -> *) a b.
Monad m =>
NonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.nonemptyFold forall a. Ord a => NonemptyFold a a
Nonempty.maximum
maximumBy :: (a -> a -> Ordering) -> Monad m => EffectfulFold m a (Maybe a)
maximumBy :: forall a (m :: * -> *).
(a -> a -> Ordering) -> Monad m => EffectfulFold m a (Maybe a)
maximumBy a -> a -> Ordering
cmp = forall (m :: * -> *) a b.
Monad m =>
NonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.nonemptyFold (forall a. (a -> a -> Ordering) -> NonemptyFold a a
Nonempty.maximumBy a -> a -> Ordering
cmp)
minimum :: Ord a => Monad m => EffectfulFold m a (Maybe a)
minimum :: forall a (m :: * -> *).
(Ord a, Monad m) =>
EffectfulFold m a (Maybe a)
minimum = forall (m :: * -> *) a b.
Monad m =>
NonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.nonemptyFold forall a. Ord a => NonemptyFold a a
Nonempty.minimum
minimumBy :: (a -> a -> Ordering) -> Monad m => EffectfulFold m a (Maybe a)
minimumBy :: forall a (m :: * -> *).
(a -> a -> Ordering) -> Monad m => EffectfulFold m a (Maybe a)
minimumBy a -> a -> Ordering
cmp = forall (m :: * -> *) a b.
Monad m =>
NonemptyFold a b -> EffectfulFold m a (Maybe b)
Convert.nonemptyFold (forall a. (a -> a -> Ordering) -> NonemptyFold a a
Nonempty.minimumBy a -> a -> Ordering
cmp)
monoid :: Monoid a => Monad m => EffectfulFold m a a
monoid :: forall a (m :: * -> *). (Monoid a, Monad m) => EffectfulFold m a a
monoid = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Monoid a => Fold a a
Pure.monoid
null :: Monad m => EffectfulFold m a Bool
null :: forall (m :: * -> *) a. Monad m => EffectfulFold m a Bool
null = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold forall a. ShortcutFold a Bool
Shortcut.null
length :: Monad m => EffectfulFold m a Natural
length :: forall (m :: * -> *) a. Monad m => EffectfulFold m a Natural
length = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Fold a Natural
Pure.length
and :: Monad m => EffectfulFold m Bool Bool
and :: forall (m :: * -> *). Monad m => EffectfulFold m Bool Bool
and = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold ShortcutFold Bool Bool
Shortcut.and
or :: Monad m => EffectfulFold m Bool Bool
or :: forall (m :: * -> *). Monad m => EffectfulFold m Bool Bool
or = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold ShortcutFold Bool Bool
Shortcut.or
all :: Monad m => (a -> Bool) -> EffectfulFold m a Bool
all :: forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> EffectfulFold m a Bool
all a -> Bool
predicate = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. (a -> Bool) -> ShortcutFold a Bool
Shortcut.all a -> Bool
predicate)
any :: Monad m => (a -> Bool) -> EffectfulFold m a Bool
any :: forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> EffectfulFold m a Bool
any a -> Bool
predicate = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. (a -> Bool) -> ShortcutFold a Bool
Shortcut.any a -> Bool
predicate)
sum :: Num a => Monad m => EffectfulFold m a a
sum :: forall a (m :: * -> *). (Num a, Monad m) => EffectfulFold m a a
sum = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Num a => Fold a a
Pure.sum
product :: Num a => Monad m => EffectfulFold m a a
product :: forall a (m :: * -> *). (Num a, Monad m) => EffectfulFold m a a
product = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Num a => Fold a a
Pure.product
mean :: Fractional a => Monad m => EffectfulFold m a a
mean :: forall a (m :: * -> *).
(Fractional a, Monad m) =>
EffectfulFold m a a
mean = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Fractional a => Fold a a
Pure.mean
variance :: Fractional a => Monad m => EffectfulFold m a a
variance :: forall a (m :: * -> *).
(Fractional a, Monad m) =>
EffectfulFold m a a
variance = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Fractional a => Fold a a
Pure.variance
standardDeviation :: Floating a => Monad m => EffectfulFold m a a
standardDeviation :: forall a (m :: * -> *).
(Floating a, Monad m) =>
EffectfulFold m a a
standardDeviation = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Floating a => Fold a a
Pure.standardDeviation
element :: Eq a => Monad m => a -> EffectfulFold m a Bool
element :: forall a (m :: * -> *).
(Eq a, Monad m) =>
a -> EffectfulFold m a Bool
element a
a = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. Eq a => a -> ShortcutFold a Bool
Shortcut.element a
a)
notElement :: Eq a => Monad m => a -> EffectfulFold m a Bool
notElement :: forall a (m :: * -> *).
(Eq a, Monad m) =>
a -> EffectfulFold m a Bool
notElement a
a = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. Eq a => a -> ShortcutFold a Bool
Shortcut.notElement a
a)
find :: Monad m => (a -> Bool) -> EffectfulFold m a (Maybe a)
find :: forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> EffectfulFold m a (Maybe a)
find a -> Bool
ok = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. (a -> Bool) -> ShortcutFold a (Maybe a)
Shortcut.find a -> Bool
ok)
index :: Monad m => Natural -> EffectfulFold m a (Maybe a)
index :: forall (m :: * -> *) a.
Monad m =>
Natural -> EffectfulFold m a (Maybe a)
index Natural
i = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. Natural -> ShortcutFold a (Maybe a)
Shortcut.index Natural
i)
elementIndex :: Eq a => Monad m => a -> EffectfulFold m a (Maybe Natural)
elementIndex :: forall a (m :: * -> *).
(Eq a, Monad m) =>
a -> EffectfulFold m a (Maybe Natural)
elementIndex a
a = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. Eq a => a -> ShortcutFold a (Maybe Natural)
Shortcut.elementIndex a
a)
findIndex :: Monad m => (a -> Bool) -> EffectfulFold m a (Maybe Natural)
findIndex :: forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> EffectfulFold m a (Maybe Natural)
findIndex a -> Bool
ok = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a. (a -> Bool) -> ShortcutFold a (Maybe Natural)
Shortcut.findIndex a -> Bool
ok)
lookup :: Eq a => Monad m => a -> EffectfulFold m (a, b) (Maybe b)
lookup :: forall a (m :: * -> *) b.
(Eq a, Monad m) =>
a -> EffectfulFold m (a, b) (Maybe b)
lookup a
a = forall (m :: * -> *) a b.
Monad m =>
ShortcutFold a b -> EffectfulFold m a b
Convert.shortcutFold (forall a b. Eq a => a -> ShortcutFold (a, b) (Maybe b)
Shortcut.lookup a
a)
list :: Monad m => EffectfulFold m a [a]
list :: forall (m :: * -> *) a. Monad m => EffectfulFold m a [a]
list = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Fold a [a]
Pure.list
reverseList :: Monad m => EffectfulFold m a [a]
reverseList :: forall (m :: * -> *) a. Monad m => EffectfulFold m a [a]
reverseList = forall (m :: * -> *) a b.
Monad m =>
Fold a b -> EffectfulFold m a b
Convert.fold forall a. Fold a [a]
Pure.reverseList