相关疑难解决方法(0)

Variadic撰写功能?

我正在尝试编写一个可变函数组合函数.基本上(.)除了第二个参数函数是可变参数之外.这应该允许表达式:

map even . zipWith (+)
Run Code Online (Sandbox Code Playgroud)

要不就

map even . zipWith
Run Code Online (Sandbox Code Playgroud)

目前,如果我添加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 …
Run Code Online (Sandbox Code Playgroud)

haskell variadic pointfree function-composition

13
推荐指数
1
解决办法
883
查看次数