可変関数合成関数を書こうとしています。これは基本的に(.)
、2 番目の引数関数が可変長であることを除いてです。これにより、次のような式が可能になります。
map even . zipWith (+)
あるいは単に
map even . zipWith
IncoherentInstances
現在、最初の引数関数に非多態性のインスタンスを追加して必要とする場合、私が到達したものは機能します。
{-# LANGUAGE FlexibleInstances, OverlappingInstances, MultiParamTypeClasses,
FunctionalDependencies, UndecidableInstances, KindSignatures #-}
class Comp a b c d | c -> d where
comp :: (a -> b) -> c -> d
instance Comp a b (a :: *) (b :: *) where
comp f g = f g
instance Comp c d b e => Comp c d (a -> b) (a -> e) where
comp f g = comp f . g
何か案は?それは可能ですか?