Я пытаюсь написать функцию вариационной функции. В основном это (.)
, за исключением того, что вторая функция аргумента является вариационной. Это должно допускать выражения типа:
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
Любые идеи? Возможно ли это?