我正在尝试移植以下 Haskell 代码(http://codepad.org/MMydRCxo)
foo :: Int -> Int -> Int -> Maybe Bool
foo a b c = if a == 1 then Just True else Nothing
bar :: Int -> Int -> Bool
bar b c = maybe False id $ foo 1 b c
-- point free
bar' :: Int -> Int -> Bool
bar' = ((maybe False id $) .) . foo 1
main = do
print $ bar 2 3
print $ bar' 2 3
到榆树,但还没有运气。( http://share-elm.com/sprout/5271f160e4b03cf6e675bc97 )
foo : Int -> Int -> Int -> Maybe Bool
foo a b c = if a == 1 then Just True else Nothing
bar : Int -> Int -> Bool
bar b c = maybe False id <| foo 1 b c
-- point free
bar' : Int -> Int -> Bool
bar' = ((maybe False id <|) .) . foo 1
main = flow down [
asText <| bar 2 3
, asText <| bar' 2 3]
如果有可能在 Elm 中使这个工作点免费,有什么想法吗?:)
多比