on master help sign in
Switch from ($) to (|>) and (<|).
commitdab4b7c7b8baf08b7a3c60dd46abb48510976f93 authorevancz <info@elm-lang.org> dateWed 24 Apr 2013, 22:26 (14 years ago) parentac67dbd
2 files changed+20−4
compiler/Parse/Library.hs+1−1 libraries/Prelude.elm+19−3
compiler/Parse/Library.hs+1−1
@@ -6,7 +6,7 @@ import Context
66import Control.Applicative ((<$>),(<*>))
77import Control.Monad
88import Control.Monad.State
9−import Data.Char (isSymbol,isUpper)
9+import Data.Char (isUpper)
1010import Rename (deprime)
1111import Text.Parsec hiding (newline,spaces,State)
1212import Text.Parsec.Indent
libraries/Prelude.elm+19−3
@@ -127,12 +127,28 @@ readFloat : String -> Maybe Float
127127-- Function composition: f . g == (\x -> f (g x))
128128(.) : (b -> c) -> (a -> b) -> (a -> c)
129129
130−-- Function application `f $ x == f x`. This function is useful for avoiding
130+-- Forward function application `x |> f == f x`. This function is useful
131+-- for avoiding parenthesis and writing code in a more natural way.
132+-- Consider the following code to create a pentagon:
133+--
134+-- scale 2 (move 100 100 (filled blue (ngon 5 30)))
135+--
136+-- This can also be written as:
137+--
138+-- ngon 5 30 |> filled blue
139+-- |> move 100 100
140+-- |> scale 2
141+(|>) : a -> (a -> b) -> b
142+
143+-- Function application `f <| x == f x`. This function is useful for avoiding
131144-- parenthesis. Consider the following code to create a text element:
145+--
132146-- text (monospace (toText "code"))
147+--
133148-- This can also be written as:
134−-- text . monospace $ toText "code"
135−($) : (a -> b) -> a -> b
149+--
150+-- text . monospace <| toText "code"
151+(<|) : (a -> b) -> a -> b
136152
137153-- Given a value, returns exactly the same value.
138154id : a -> a