関数の arity を調べる関数
IncoherentInstances よくわかりません
{-# LANGUAGE MultiParamTypeClasses , FunctionalDependencies , TypeFamilies , FlexibleInstances , ScopedTypeVariables , EmptyDataDecls , UndecidableInstances , IncoherentInstances #-} data Z data S a class Arity f n | f -> n where arity :: f -> n arity = undefined instance (n ~ Z) => Arity x n instance (Arity y n, S n ~ n') => Arity (x -> y) n' class Nat n where toInt :: n -> Int instance Nat Z where toInt _ = 0 instance Nat n => Nat (S n) where toInt _ = 1 + toInt (undefined :: n) main = do print . toInt . arity $ 42 print . toInt . arity $ length print . toInt . arity $ (+) print . toInt . arity $ zipWith