从haskell功能返回的优雅方式?

dan*_*dhi -1 haskell

嗨,我是哈斯凯尔的新手.

我想要回报一些类似的东西

return ((myfunc list1) ++ list2 )
Run Code Online (Sandbox Code Playgroud)

这里list1和list2是两个列表,myfunc也返回一个列表

我最优雅的做法是什么.我应该使用$运算符吗?提前致谢 :)

Dan*_*ner 5

我会这样做:

foo list1 list2 = myfunc list1 ++ list2
Run Code Online (Sandbox Code Playgroud)

如果你真的需要return(我怀疑你没有),那么$可能需要使用; 但明确括号内的版本也完全没问题:

foo list1 list2 = return (myfunc list1 ++ list2)
foo list1 list2 = return $ myfunc list1 ++ list2
Run Code Online (Sandbox Code Playgroud)