我知道TypeSynomymInstances只允许在实例头中使用完全应用的类型同义词,但是如果我可以使用paritally应用的类型同义词,它似乎也很方便.
例如:
class Example e where
thingy :: a -> b -> e a b
-- legit, but awkward
newtype FuncWrapper e a b = FuncWrapper { ap :: a -> e a b }
instance (Example e) => Example (FuncWrapper e) where
thingy _ = FuncWrapper . flip thingy
funcWrapperUse :: (Example e) => e Int String
funcWrapperUse = thingy 1 "two" `ap` 3 `ap` 4 `ap` 5
-- not legal, but a little easier to use …Run Code Online (Sandbox Code Playgroud) haskell ×1