File: lambda-case-out.hs

package info (click to toggle)
haskell-ormolu 0.7.2.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,528 kB
  • sloc: haskell: 16,077; makefile: 7
file content (23 lines) | stat: -rw-r--r-- 415 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE LambdaCase #-}

foo = bar (\case JKey {} -> True; _ -> False)

foo :: Int -> Int
foo = \case
  5 -> 10
  i | i > 5 -> 11
  _ -> 12

foo :: Maybe a -> Maybe a -> Maybe a -> Int
foo = \cases Nothing Just {} Nothing -> 1; _ _ _ -> 0

foo :: Maybe Int -> Maybe Int -> Int
foo = \cases
  (Just a) (Just a) -> a + a
  _ _ -> 0

foo :: Bool -> Bool -> Bool
foo = \cases
  True
    True -> True
  _ _ -> False