在Python中,我们有一个名为“operator”的内置包,我们可以使用它的任何操作符的函数版本。当使用map和reduce等“函数式编程”功能时,它的使用率很高,并且比使用“lambda”更好。什么是Haskell中的“::”等价函数?
我在Haskell同样的问题:我想用的许多功能组成某处T的用户MAPM,但我不得不使用不那么漂亮的λ:
mapM ((\x->x::String).fromSql.(!!1)) res
是否有任何相当于liek这样的:
mapM (someFunc(String).fromSql.(!!1)) res
可以在GHC 8.0中做“id @String”:https://ghc.haskell.org/trac/ghc/wiki/TypeApplication –
'mapM(asTypeOf“”.fromSql。(!! 1)) res' - 除非你有'XOverloadedStrings'。 – Michael
你确定'mapM(fromSql。(!! 1))res'是不够的,或者'mapM((fromSql。(!! 1)):: a - > String)res'? – chepner