on master help sign in
Switch from ($) to (|>) and (<|).
dab4b7cevancz
compiler/Parse/Library.hs+1−1
@@ -6,7 +6,7 @@ import Context
6import Control.Applicative ((<$>),(<*>))
6import Control.Applicative ((<$>),(<*>))
7import Control.Monad
7import Control.Monad
8import Control.Monad.State
8import Control.Monad.State
9−import Data.Char (isSymbol,isUpper)
9+import Data.Char (isUpper)
10import Rename (deprime)
10import Rename (deprime)
11import Text.Parsec hiding (newline,spaces,State)
11import Text.Parsec hiding (newline,spaces,State)
12import Text.Parsec.Indent
12import Text.Parsec.Indent
libraries/Prelude.elm+19−3
@@ -127,12 +127,28 @@ readFloat : String -> Maybe Float
127-- Function composition: f . g == (\x -> f (g x))
127-- Function composition: f . g == (\x -> f (g x))
128(.) : (b -> c) -> (a -> b) -> (a -> c)
128(.) : (b -> c) -> (a -> b) -> (a -> c)
129
129
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+
130−-- Function application `f $ x == f x`. This function is useful for avoiding
143+-- Function application `f <| x == f x`. This function is useful for avoiding
131-- parenthesis. Consider the following code to create a text element:
144-- parenthesis. Consider the following code to create a text element:
145+--
132-- text (monospace (toText "code"))
146-- text (monospace (toText "code"))
147+--
133-- This can also be written as:
148-- This can also be written as:
149+--
134−-- text . monospace $ toText "code"
150+-- text . monospace <| toText "code"
135−($) : (a -> b) -> a -> b
151+(<|) : (a -> b) -> a -> b
136
152
137-- Given a value, returns exactly the same value.
153-- Given a value, returns exactly the same value.
138id : a -> a
154id : a -> a