| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Function
Synopsis
- ($) :: (a -> b) -> a -> b
 - ($!) :: (a -> b) -> a -> b
 - (&) :: a -> (a -> b) -> b
 - asTypeOf :: a -> a -> a
 - const :: a -> b -> a
 - fix :: (a -> a) -> a
 - flip :: (a -> b -> c) -> b -> a -> c
 - loop :: (a -> Either a b) -> a -> b
 - on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
 - until :: (a -> Bool) -> (a -> a) -> a -> a
 - curry :: ((a, b) -> c) -> a -> b -> c
 - curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d
 - uncurry :: (a -> b -> c) -> (a, b) -> c
 - uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
 - newtype Endo a = Endo {
- appEndo :: a -> a
 
 - newtype Op a b = Op {
- getOp :: b -> a
 
 
Documentation
($) :: (a -> b) -> a -> b infixr 0 #
Application operator.  This operator is redundant, since ordinary
 application (f x) means the same as (f . However, $ x)$ has
 low, right-associative binding precedence, so it sometimes allows
 parentheses to be omitted; for example:
f $ g $ h x = f (g (h x))
It is also useful in higher-order situations, such as ,
 or map ($ 0) xs.zipWith ($) fs xs
($!) :: (a -> b) -> a -> b infixr 0 #
Strict (call-by-value) application operator. It takes a function and an argument, evaluates the argument to weak head normal form (WHNF), then calls the function with that value.
const x is a unary function which evaluates to x for all inputs.
>>>const 42 "hello"42
>>>map (const 42) [0..3][42,42,42,42]
 is the least fixed point of the function fix ff,
 i.e. the least defined x such that f x = x.
For example, we can write the factorial function using direct recursion as
>>>let fac n = if n <= 1 then 1 else n * fac (n-1) in fac 5120
This uses the fact that Haskell’s let introduces recursive bindings. We can
 rewrite this definition using fix,
>>>fix (\rec n -> if n <= 1 then 1 else n * rec (n-1)) 5120
Instead of making a recursive call, we introduce a dummy parameter rec;
 when used within fix, this parameter then refers to fix' argument, hence
 the recursion is reintroduced.
flip :: (a -> b -> c) -> b -> a -> c #
 takes its (first) two arguments in the reverse order of flip ff.
>>>flip (++) "hello" "world""worldhello"
until :: (a -> Bool) -> (a -> a) -> a -> a #
 yields the result of applying until p ff until p holds.
curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d #
Converts an uncurried function to a curried function.
uncurry :: (a -> b -> c) -> (a, b) -> c #
uncurry converts a curried function to a function on pairs.
Examples
>>>uncurry (+) (1,2)3
>>>uncurry ($) (show, 1)"1"
>>>map (uncurry max) [(1,2), (3,4), (6,8)][2,4,8]
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d #
Converts a curried function to a function on a triple.
The monoid of endomorphisms under composition.
>>>let computation = Endo ("Hello, " ++) <> Endo (++ "!")>>>appEndo computation "Haskell""Hello, Haskell!"
Instances
| Pointed Endo | |
Defined in Data.Pointed  | |
| Generic (Endo a) | |
| Semigroup (Endo a) | Since: base-4.9.0.0  | 
| Monoid (Endo a) | Since: base-2.1  | 
| Wrapped (Endo a) | |
| Lower (Endo a) | |
Defined in Data.Semilattice.Lower Methods lowerBound :: Endo a #  | |
| t ~ Endo b => Rewrapped (Endo a) t | |
Defined in Control.Lens.Wrapped  | |
| type Rep (Endo a) | |
Defined in Data.Semigroup.Internal  | |
| type Unwrapped (Endo a) | |
Defined in Control.Lens.Wrapped  | |
Dual function arrows.
Instances
| Contravariant (Op a) | |
| Monoid r => Divisible (Op r) | |
| Monoid r => Decidable (Op r) | |
| Category Op | |
| Semigroupoid Op | |
| Floating a => Floating (Op a b) | |
| Fractional a => Fractional (Op a b) | |
| Num a => Num (Op a b) | |
| Semigroup a => Semigroup (Op a b) | |
| Monoid a => Monoid (Op a b) | |
| Wrapped (Op a b) | |
| t ~ Op a' b' => Rewrapped (Op a b) t | |
Defined in Control.Lens.Wrapped  | |
| type Unwrapped (Op a b) | |
Defined in Control.Lens.Wrapped  | |