Take the tour ×  Today I played with using type classes to
inductively construct functions of a predicate of any arity
taking as inputs any combination of any types, that returned
other predicates of the same type but with some basic operation
applied. For example  conjunction (>2) even  would return a
predicate that evaluates to true for even numbers larger than
two and  conjunction (>=) (<=)  would return =  All well and
good, got that part working, but it raised the question, what if
I wanted to define conjunction of two predicates as being a
predicate that takes one input for each input of each conjoined
predicate? For example:  :t conjunction (>) not  would return
Ord a => a -> a -> Bool -> Bool. Can this be done? If so, how?
share|improve this question add comment  2 Answers  up vote 6
down vote accepted  We will need TypeFamilies for this solution.
{-# LANGUAGE TypeFamilies #-}  The idea is to define a class
Pred for n-ary predicates:  class Pred a where   type Arg a k ::
*   split :: a -> (Bool -> r