如何指定两个类型变量相同?

时间:2019-04-14 04:48:26

标签: haskell types type-signature

说这样的代码:

fun :: (a -> b) -> [a] -> [b]
fun f as = someLogic as
  where someLogic :: [a] -> [b]
        someLogic xs = map f xs

编译器会抱怨最后一行,“ a”的类型f与“ a”的类型someLogic不同。

那么我该怎么做才能让编译器知道两种类型的a是同一件事?

0 个答案:

没有答案