module Fold.Shortcut.Examples.Boring
(
sum, product, mean, variance, standardDeviation,
length,
maximum, minimum, maximumBy, minimumBy,
first, last,
magma, semigroup, monoid,
list, reverseList,
)
where
import Data.Maybe (Maybe)
import Fold.Shortcut.Type (ShortcutFold)
import Data.Semigroup (Semigroup)
import Data.Ord (Ord, Ordering (GT), max, min)
import Data.Monoid (Monoid)
import Prelude (Floating, Fractional, Num)
import Numeric.Natural (Natural)
import qualified Fold.ShortcutNonempty.Examples.Interesting as ShortcutNonempty
import qualified Fold.Nonempty.Examples.Interesting as Nonempty
import qualified Fold.Pure.Examples.Interesting as Fold
import qualified Fold.Shortcut.Conversion as Convert
first :: ShortcutFold a (Maybe a)
first :: forall a. ShortcutFold a (Maybe a)
first = forall a b. ShortcutNonemptyFold a b -> ShortcutFold a (Maybe b)
Convert.shortcutNonemptyFold forall a. ShortcutNonemptyFold a a
ShortcutNonempty.first
magma :: (a -> a -> a) -> ShortcutFold a (Maybe a)
magma :: forall a. (a -> a -> a) -> ShortcutFold a (Maybe a)
magma a -> a -> a
step = forall a b. NonemptyFold a b -> ShortcutFold a (Maybe b)
Convert.nonemptyFold (forall a. (a -> a -> a) -> NonemptyFold a a
Nonempty.magma a -> a -> a
step)
semigroup :: Semigroup a => ShortcutFold a (Maybe a)
semigroup :: forall a. Semigroup a => ShortcutFold a (Maybe a)
semigroup = forall a b. NonemptyFold a b -> ShortcutFold a (Maybe b)
Convert.nonemptyFold forall a. Semigroup a => NonemptyFold a a
Nonempty.semigroup
last :: ShortcutFold a (Maybe a)
last :: forall a. ShortcutFold a (Maybe a)
last = forall a b. NonemptyFold a b -> ShortcutFold a (Maybe b)
Convert.nonemptyFold forall a. NonemptyFold a a
Nonempty.last
maximum :: Ord a => ShortcutFold a (Maybe a)
maximum :: forall a. Ord a => ShortcutFold a (Maybe a)
maximum = forall a. (a -> a -> a) -> ShortcutFold a (Maybe a)
magma forall a. Ord a => a -> a -> a
max
maximumBy :: (a -> a -> Ordering) -> ShortcutFold a (Maybe a)
maximumBy :: forall a. (a -> a -> Ordering) -> ShortcutFold a (Maybe a)
maximumBy a -> a -> Ordering
cmp = forall a. (a -> a -> a) -> ShortcutFold a (Maybe a)
magma (\a
x a
y -> case a -> a -> Ordering
cmp a
x a
y of { Ordering
GT -> a
x; Ordering
_ -> a
y })
minimum :: Ord a => ShortcutFold a (Maybe a)
minimum :: forall a. Ord a => ShortcutFold a (Maybe a)
minimum = forall a. (a -> a -> a) -> ShortcutFold a (Maybe a)
magma forall a. Ord a => a -> a -> a
min
minimumBy :: (a -> a -> Ordering) -> ShortcutFold a (Maybe a)
minimumBy :: forall a. (a -> a -> Ordering) -> ShortcutFold a (Maybe a)
minimumBy a -> a -> Ordering
cmp = forall a. (a -> a -> a) -> ShortcutFold a (Maybe a)
magma (\a
x a
y -> case a -> a -> Ordering
cmp a
x a
y of { Ordering
GT -> a
y; Ordering
_ -> a
x })
list :: ShortcutFold a [a]
list :: forall a. ShortcutFold a [a]
list = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Fold a [a]
Fold.list
reverseList :: ShortcutFold a [a]
reverseList :: forall a. ShortcutFold a [a]
reverseList = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Fold a [a]
Fold.reverseList
monoid :: Monoid a => ShortcutFold a a
monoid :: forall a. Monoid a => ShortcutFold a a
monoid = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Monoid a => Fold a a
Fold.monoid
length :: ShortcutFold a Natural
length :: forall a. ShortcutFold a Natural
length = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Fold a Natural
Fold.length
sum :: Num a => ShortcutFold a a
sum :: forall a. Num a => ShortcutFold a a
sum = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Num a => Fold a a
Fold.sum
product :: Num a => ShortcutFold a a
product :: forall a. Num a => ShortcutFold a a
product = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Num a => Fold a a
Fold.product
mean :: Fractional a => ShortcutFold a a
mean :: forall a. Fractional a => ShortcutFold a a
mean = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Fractional a => Fold a a
Fold.mean
variance :: Fractional a => ShortcutFold a a
variance :: forall a. Fractional a => ShortcutFold a a
variance = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Fractional a => Fold a a
Fold.variance
standardDeviation :: Floating a => ShortcutFold a a
standardDeviation :: forall a. Floating a => ShortcutFold a a
standardDeviation = forall a b. Fold a b -> ShortcutFold a b
Convert.fold forall a. Floating a => Fold a a
Fold.standardDeviation