hsfoldr :: (Maybe (a, b) -> b) -> [a] -> b foldr f [] = f Nothing foldr f (x:xs) = f (Just (x, foldr f xs))
hs{-# LANGUAGE LambdaCase #-} sum :: [Int] -> Int sum = foldr $ \case Just (cur, acc) -> cur + acc Nothing -> 0