-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | simple alternative to type classes -- @package cluss @version 0.1 module Type.Cluss -- | In as is a cluss, where as is a list -- of type patterns. Normally, as is concrete and does not -- contain any type variables, like In [Binary (->) (Show -- >|< This), Type String] a. -- -- When a satisfies In as a, you can use the method -- proj :: AllOf as f -> f a. -- -- Clusses call for some language extensions. Basically, this language -- pragma will do. -- --
--   {-# LANGUAGE DataKinds, FlexibleContexts, TypeOperators #-}
--   
-- -- Internally, "type pattern matching" is executed by Where, a -- closed type family, which cannot check if a type satisfies a -- constraint. If as has many type patterns that can match -- a, only the first one matches a. class In (as :: [*]) (a :: k) proj :: In as a => AllOf as f -> f a -- | The empty type Type a is a type pattern. For example, the -- type pattern Type Int corresponds to instance C Int where -- ... (C is a type class). Note that the type variable -- a can be of any kind. data Type (a :: k) -- | The empty type a <| p is a type pattern, where a -- is a type constructor, and p is a constraint function for the -- type variables for the constructor a. For example, the type -- pattern [] <| Show corresponds to instance (Show a) -- => C [a] where ... (C is a type class). -- -- You can replace any of Unary, Binary, ..., Senary -- with <|, but you can sometimes save the effort of -- annotating kinds using Unary, Binary, ..., Senary -- instead of <|, especially when using PolyKinds -- extension, because kinds of parameters are restricted in Unary, -- Binary, ..., Senary. data (<|) (a :: k) (p :: l) -- | a <| p, with a being of the kind i -- -> k and p, i -> Constraint. type Unary (a :: i -> k) (p :: i -> Constraint) = a <| p -- | a <| p, with a being of the kind i -- -> i' -> k and p, i -> i' -> -- Constraint. type Binary (a :: i -> i' -> k) (p :: i -> i' -> Constraint) = a <| p -- | a <| p, with a being of the kind i -- -> i' -> i'' -> k and p, i -> i' -> -- i'' -> Constraint. type Ternary (a :: i -> i' -> k) (p :: i -> i' -> i'' -> Constraint) = a <| p -- | a <| p, with a being of the kind i -- -> i' -> i'' -> i''' -> k and p, i -> -- i' -> i'' -> i''' -> Constraint. type Quaternary (a :: i -> i' -> i'' -> i''' -> k) (p :: i -> i' -> i'' -> i''' -> Constraint) = a <| p -- | a <| p, with a being of the kind i -- -> i' -> i'' -> i''' -> i'''' -> k and p, -- i -> i' -> i'' -> i''' -> i'''' -> -- Constraint. type Quinary (a :: i -> i' -> i'' -> i''' -> i'''' -> k) (p :: i -> i' -> i'' -> i''' -> i'''' -> Constraint) = a <| p -- | a <| p, with a being of the kind i -- -> i' -> i'' -> i''' -> i'''' -> i''''' -> k -- and p, i -> i' -> i'' -> i''' -> i'''' -> -- i''''' -> Constraint. type Senary (a :: i -> i' -> i'' -> i''' -> i'''' -> i''''' -> k) (p :: i -> i' -> i'' -> i''' -> i'''' -> i''''' -> Constraint) = a <| p -- | AllOf as f is a tuple that contains values of the type -- f a, where a can be any type that satisfies In -- as a. Each value corresponds to each type pattern, and the values -- in AllOf as f must be in the same order as the type -- patterns in as. And, And1, And2, ..., -- And6 are used to combine the values and None must be -- added at the end. You have to use And for Type -- a, And1 for Unary a p, And2 for -- Binary a p, ..., And6 for Senary a -- p. type AllOf as = AllOf' as as -- | This creates a recursion. In other words, This will work -- as In as itself when used in the type list (first -- parameter) as of In, combined with Type, -- <|, Unary, Binary, ..., Senary, -- >+<, >++<, ..., >++++++<, -- >|<, >||<, ..., >|||||<. -- -- Note that This won't be expanded into In as if -- the condition described above is not satisfied. Internally, the -- expansion is executed by Modify, Modify2, ..., -- Modify6. -- -- The instance of This itself can't be created since the context -- True~False will never be satisfied. -- -- There is no predetermined limit of recursion depth, but GHC has a -- fixed-depth recursion stack for safety, so you may need to increase -- the stack depth with -fcontext-stack=N. class True ~ False => This (a :: k) -- | Pure a is equivalent to the empty constraint -- (). -- --
--   Pure a == ()
--   
class Pure (a :: i) -- |
--   (Is a) b == (a ~ b)
--   
type Is a b = a ~ b -- |
--   (p >+< q) a == (p a, q a)
--   
class (p a, q a) => (>+<) p q a -- |
--   (p >++< q) a b == (p a b, q a b)
--   
class (p a b, q a b) => (>++<) p q a b -- |
--   (p >+++< q) a b c == (p a b c, q a b c)
--   
class (p a b c, q a b c) => (>+++<) p q a b c -- |
--   (p >++++< q) a b c d == (p a b c d, q a b c d)
--   
class (p a b c d, q a b c d) => (>++++<) p q a b c d -- |
--   (p >+++++< q) a b c d e == (p a b c d e, q a b c d e)
--   
class (p a b c d e, q a b c d e) => (>+++++<) p q a b c d e -- |
--   (p >++++++< q) a b c d e f == (p a b c d e f, q a b c d e f)
--   
class (p a b c d e f, q a b c d e f) => (>++++++<) p q a b c d e f -- |
--   (p >|< q) a b == (p a, q b)
--   
class (p a, q b) => (>|<) p q a b -- |
--   (p >||< q) a b c == (p a b, q c)
--   
class (p a b, q c) => (>||<) p q a b c -- |
--   (p >|||< q) a b c d == (p a b c, q d)
--   
class (p a b c, q d) => (>|||<) p q a b c d -- |
--   (p >||||< q) a b c d e == (p a b c d, q e)
--   
class (p a b c d, q e) => (>||||<) p q a b c d e -- |
--   (p >|||||< q) a b c d e f == (p a b c d e, q f)
--   
class (p a b c d e, q f) => (>|||||<) p q a b c d e f type AllOfI as = AllOfI' as as type AllOfI' ts as = AllOf' ts as Id andI :: a -> AllOfI' ts as -> AllOfI' ts (Type a : as) andI1 :: (forall b. Modify (In ts) p b => a b) -> AllOfI' ts as -> AllOfI' ts ((a <| p) : as) andI2 :: (forall b c. Modify2 (In ts) p b c => a b c) -> AllOfI' ts as -> AllOfI' ts ((a <| p) : as) andI3 :: (forall b c d. Modify3 (In ts) p b c d => a b c d) -> AllOfI' ts as -> AllOfI' ts ((a <| p) : as) andI4 :: (forall b c d e. Modify4 (In ts) p b c d e => a b c d e) -> AllOfI' ts as -> AllOfI' ts ((a <| p) : as) andI5 :: (forall b c d e f. Modify5 (In ts) p b c d e f => a b c d e f) -> AllOfI' ts as -> AllOfI' ts ((a <| p) : as) andI6 :: (forall b c d e f g. Modify6 (In ts) p b c d e f g => a b c d e f g) -> AllOfI' ts as -> AllOfI' ts ((a <| p) : as) noneI :: AllOfI' ts [] projI :: In as a => AllOfI as -> a type AllOfF as t = AllOfF' as as t type AllOfF' ts as t = AllOf' ts as (Func t) andF :: (a -> t) -> AllOfF' ts as t -> AllOfF' ts (Type a : as) t andF1 :: (forall b. Modify (In ts) p b => a b -> t) -> AllOfF' ts as t -> AllOfF' ts ((a <| p) : as) t andF2 :: (forall b c. Modify2 (In ts) p b c => a b c -> t) -> AllOfF' ts as t -> AllOfF' ts ((a <| p) : as) t andF3 :: (forall b c d. Modify3 (In ts) p b c d => a b c d -> t) -> AllOfF' ts as t -> AllOfF' ts ((a <| p) : as) t andF4 :: (forall b c d e. Modify4 (In ts) p b c d e => a b c d e -> t) -> AllOfF' ts as t -> AllOfF' ts ((a <| p) : as) t andF5 :: (forall b c d e f. Modify5 (In ts) p b c d e f => a b c d e f -> t) -> AllOfF' ts as t -> AllOfF' ts ((a <| p) : as) t andF6 :: (forall b c d e f g. Modify6 (In ts) p b c d e f g => a b c d e f g -> t) -> AllOfF' ts as t -> AllOfF' ts ((a <| p) : as) t noneF :: AllOfF' ts [] t projF :: In as a => AllOfF as t -> (a -> t) instance In' n ts as a => In' (Look_At_Tail n) ts ((b <| p) : as) a instance In' n ts as a => In' (Look_At_Tail n) ts ((b <| p) : as) a instance In' n ts as a => In' (Look_At_Tail n) ts ((b <| p) : as) a instance In' n ts as a => In' (Look_At_Tail n) ts ((b <| p) : as) a instance In' n ts as a => In' (Look_At_Tail n) ts ((b <| p) : as) a instance In' n ts as a => In' (Look_At_Tail n) ts ((b <| p) : as) a instance In' n ts as a => In' (Look_At_Tail n) ts (Type b : as) a instance (Modify6 (In ts) p b c d e f g) => In' Look_At_Head ts ((a <| p) : as) (a b c d e f g) instance (Modify5 (In ts) p b c d e f) => In' Look_At_Head ts ((a <| p) : as) (a b c d e f) instance (Modify4 (In ts) p b c d e) => In' Look_At_Head ts ((a <| p) : as) (a b c d e) instance (Modify3 (In ts) p b c d) => In' Look_At_Head ts ((a <| p) : as) (a b c d) instance (Modify2 (In ts) p b c) => In' Look_At_Head ts ((a <| p) : as) (a b c) instance (Modify (In ts) p b) => In' Look_At_Head ts ((a <| p) : as) (a b) instance In' Look_At_Head ts (Type a : as) a instance In' (Where as a) as as a => In as a instance (p a b c d e, q f) => (>|||||<) p q a b c d e f instance (p a b c d, q e) => (>||||<) p q a b c d e instance (p a b c, q d) => (>|||<) p q a b c d instance (p a b, q c) => (>||<) p q a b c instance (p a, q b) => (>|<) p q a b instance (p a b c d e f, q a b c d e f) => (>++++++<) p q a b c d e f instance (p a b c d e, q a b c d e) => (>+++++<) p q a b c d e instance (p a b c d, q a b c d) => (>++++<) p q a b c d instance (p a b c, q a b c) => (>+++<) p q a b c instance (p a b, q a b) => (>++<) p q a b instance (p a, q a) => (>+<) p q a instance Pure a