{-# LANGUAGE TypeOperators, LiberalTypeSynonyms, RankNTypes,
ConstraintKinds, KindSignatures, TypeFamilies,
PolyKinds, DataKinds, CPP, MultiParamTypeClasses,
UndecidableSuperClasses, FlexibleInstances #-}
module Control.Type.Operator ( type (^>), type (<^), type ($), type (&)
, type ($$), type (<+>), type (<=>)
) where
#if __GLASGOW_HASKELL__ <= 710
import GHC.Prim (Constraint)
#else
import Data.Kind (Constraint)
#endif
type (^>) = (->)
infixr 5 ^>
type (<^) a b = (^>) b a
infixr 5 <^
type f $ a = f a
infixr 2 $
type a & f = f a
infixl 1 &
type (f $$ a) b = f a b
infixr 3 $$
type family (<=>) (c :: k -> Constraint) (as :: [k]) where
(<=>) c '[k] = c k
(<=>) c (h ': t) = (c h, (<=>) c t)
infixl 9 <=>
-- | Map several constraints over a single variable.
--
-- @
-- a :: [Show, Read] \<+> a => a -> a
-- =
-- a :: (Show a, Read a) => a -> a
-- @
type family (<+>) (c :: [k -> Constraint]) (a :: k) where
(<+>) '[] a = (() :: Constraint)
(<+>) (ch ': ct) a = (ch a, (<+>) ct a)
infixl 9 <+>