Added (&)
. Fixes #28
For newer versions of base this will just re-export `Data.Function.(&)` and for older versions I backport the definition. The purpose of this to allow users to write pipelines from left to right and without lots of parentheses, like this: "123" + "456" & grep "123" & stdout Thanks to @FranklinChen for the suggestion
This commit is contained in:
parent
119179ad2e
commit
e120c0555a
1 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
-- | See "Turtle.Tutorial" to learn how to use this library or "Turtle.Prelude"
|
-- | See "Turtle.Tutorial" to learn how to use this library or "Turtle.Prelude"
|
||||||
-- for a quick-start guide.
|
-- for a quick-start guide.
|
||||||
--
|
--
|
||||||
|
@ -81,6 +83,7 @@ module Turtle (
|
||||||
, Handle
|
, Handle
|
||||||
, ExitCode(..)
|
, ExitCode(..)
|
||||||
, IsString(..)
|
, IsString(..)
|
||||||
|
, (&)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Turtle.Format
|
import Turtle.Format
|
||||||
|
@ -141,3 +144,15 @@ import Data.Time (NominalDiffTime, UTCTime)
|
||||||
import System.IO (Handle)
|
import System.IO (Handle)
|
||||||
import System.Exit (ExitCode(..))
|
import System.Exit (ExitCode(..))
|
||||||
import Prelude hiding (FilePath)
|
import Prelude hiding (FilePath)
|
||||||
|
|
||||||
|
#if MIN_VERSION_base(4,8,0)
|
||||||
|
import Data.Function ((&))
|
||||||
|
#else
|
||||||
|
infixl 1 &
|
||||||
|
|
||||||
|
-- | '&' is a reverse application operator. This provides notational
|
||||||
|
-- convenience. Its precedence is one higher than that of the forward
|
||||||
|
-- application operator '$', which allows '&' to be nested in '$'.
|
||||||
|
(&) :: a -> (a -> b) -> b
|
||||||
|
x & f = f x
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue