antelude-0.1.0: Yet another alternative Prelude for Haskell.
Maintainerdneavesdev@pm.me
Safe HaskellSafe
LanguageGHC2021

Antelude.Function

Description

I realized after-the-fact that the arrows (which I was taking inspiration from Elm) is essentially part of what the flow package does.

Synopsis

Documentation

constant :: a -> b -> a Source #

Always return the first argument.

identity :: a -> a Source #

Re-return the first argument. Can be surprisingly useful.

Reexport from Function

flip :: (a -> b -> c) -> b -> a -> c #

flip f takes its (first) two arguments in the reverse order of f.

>>> flip (++) "hello" "world"
"worldhello"

Reexport from Prelude

asTypeOf :: a -> a -> a #

asTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the second.

Reexport from Prelude

seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b infixr 0 #

The value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness.

A note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. If you need to guarantee a specific order of evaluation, you must use the function pseq from the "parallel" package.

(.>) :: (a -> b) -> (b -> c) -> a -> c infixr 9 Source #

Equivalent to 'flip (.)', but in an arrowhead format.

Since (>>) is already a typeclass-locked Haskell symbol for Monad, (.>) was decided as was decided as it's (.) but with a direction.

(<.) :: (b -> c) -> (a -> b) -> a -> c infixl 9 Source #

Equivalent to (.) from Function, but in an arrowhead format.

Since (<<) would be confused with 'flip (>>)', (<.) was decided as it's (.) but with a direction.

(<|) :: (a -> b) -> a -> b infixr 0 Source #

Equivalent to ($) from Function, but like Elm. Can be slightly clearer for unfamiliar developers.

(|>) :: a -> (a -> b) -> b infixl 0 Source #

Equivalent to (&) from Function, but like Elm. Can be slightly clearer for unfamiliar developers.