raise Data.Function to the type levels

This commit is contained in:
rnhmjoj 2016-11-27 20:16:23 +01:00
parent 99619b7109
commit b9f249a9ff
No known key found for this signature in database
GPG Key ID: 362BB82B7E496B7C

View File

@ -14,26 +14,36 @@
-- | Defines commonly used functions and combinators
module Data.Function where
-- | Identity Function
id (a ). a a
id x = x
import Data.Singletons.TH
-- | Constant function
const (a ) (b ). a b a
const k _ = k
singletons [d|
-- | Undefined
() a. a
() = ()
-- | Identity function
id a. a a
id x = x
-- | Constant function
const a b. a b a
const k _ = k
-- | Flip the arguments of a function
flip a b c. (a b c) (b a c)
flip f x y = f y x
-- | Undefined
() a. a
() = ()
infixr 9
-- | Function composition operator
() :: a b c. (b c) (a b) a c
f g = \x f (g x)
|]
infixr 0 $
infixr 9
-- | Function application operator
($) a b. (a b) a b
f $ x = f x
-- | Function composition operator
() :: a b c. (b c) (a b) a c
f g = \x f (g x)