Safe Haskell | Safe |
---|
Eta.Core
Description
- Eta Core
- (|>) :: a -> (a -> b) -> b
- (<|) :: (a -> b) -> a -> b
- ($) :: (a -> b) -> a -> b
- flip :: (a -> b -> c) -> b -> a -> c
- die :: String -> a
- undefined :: a
- stopIfUndefined :: a -> b -> b
- constantly :: a -> b -> a
Documentation
>>>
import Eta.Classes.Num
>>>
import Eta.Classes.Functor
>>>
import Eta.Classes.Show
>>>
import Eta.Types.IO
Pipe operator. Functions can be applied using the pipe operator, reducing parentheses and increasing the code readability.
Instead of writing
(printLine (join ", " (sort names)))
Use the pipe operator:
names |> sort |> join ", " |> printLine
Pipe backwards operator. Applies the function of the left to the value of the right.
>>>
(+ 2) <| 1
3
Application operator. Synonymous to (<|), useful for skipping a level of parentheses.
It can be read as "enclose in parentheses from here to the end of the expression."
>>>
(print $ show 4)
4
flip :: (a -> b -> c) -> b -> a -> c #
Flips the arguments of a function
>>>
subtract a b = a - b
>>>
inverseSubtract = flip subtract
>>>
subtract 3 2
1>>>
inverseSubtract 3 2
-1
Warning: Partial functions should be avoided
Stops execution and displays an error message.
Warning: Partial functions should be avoided
A value that can be of any type. The compiler will recognize this and insert an error message appropriate to the context where it appears.
Usually, also called Bottom
stopIfUndefined :: a -> b -> b #
constantly :: a -> b -> a #
Constructs a function that returns the same output for the same input
>>>
universe = constantly 42
>>>
universe 35
42>>>
map (constantly 10) [1..3]
[10,10,10]