引数の数の自動判定
*TestFunArgPerm> [f 1 2 3 | f <- permArgs' (\a b c -> [a, b, c])] [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
{-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-} {-# OPTIONS -fallow-overlapping-instances #-} permArgs' f = permArgs (nargs f) f class Nargs f where nargs :: f -> [f -> f] instance Nargs (a -> b) => Nargs (a -> a -> b) where nargs _ = suc (nargs (undefined :: a -> b)) instance Nargs (a -> b) where nargs _ = one