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 -- | Defines commonly used functions and combinators
module Data.Function where module Data.Function where
-- | Identity Function import Data.Singletons.TH
id (a ). a a
singletons [d|
-- | Identity function
id a. a a
id x = x id x = x
-- | Constant function -- | Constant function
const (a ) (b ). a b a const a b. a b a
const k _ = k 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 -- | Undefined
() a. a () a. a
() = () () = ()
infixr 0 $
infixr 9 infixr 9
-- | Function application operator
($) a b. (a b) a b
f $ x = f x
-- | Function composition operator -- | Function composition operator
() :: a b c. (b c) (a b) a c () :: a b c. (b c) (a b) a c
f g = \x f (g x) f g = \x f (g x)
|]
infixr 0 $
-- | Function application operator
($) a b. (a b) a b
f $ x = f x