LambdaCase
code:before
\x -> case x of ...
code:after
\case ...
例
ちなみにfoldrの型は、foldr :: (Maybe (a, b) -> b) -> [a] -> b
普通に書くと
code:hs
sum = foldr $ \xx -> case xx of
Just (cur, acc) -> cur + acc
Nothing -> 0
このxxの部分は、謎概念なので命名もしづらいmrsekut.icon
LambdaCaseを使うと
code:hs
{-# LANGUAGE LambdaCase #-} sum = foldr $ \case
Just (cur, acc) -> cur + acc
Nothing -> 0
code:purs(hs)
sum = foldr case _ of
Just (Tuple cur acc) -> cur + acc
Nothing -> 0
複数引数に対応した版