Skip to content

Instantly share code, notes, and snippets.

@AndrasKovacs
Last active December 1, 2022 07:20
Show Gist options
  • Save AndrasKovacs/ec65e07c713195087662c58398796501 to your computer and use it in GitHub Desktop.
Save AndrasKovacs/ec65e07c713195087662c58398796501 to your computer and use it in GitHub Desktop.
Syntax proposal for or-patterns in Haskell
-- Examples
data Foo = A | B | C
foo :: Foo -> Int
foo A = 10
foo B
foo C = 20
foo :: Foo -> Int
foo x = case x of
A -> 10
B
C -> 20
foo :: Foo -> Int
foo x = case x of A -> 10; B; C -> 20
foo :: Foo -> Int
foo x = case x of
A -> 10;
B;C -> 20
foo :: Foo -> Int
foo = \case A -> 10; B;C -> 20
-- pattern vars
data Foo = A Int | B Int | C Int
foo :: Foo -> Int
foo (A n)
foo (B n)
foo (C n) = n + 10
foo :: Foo -> Int
foo = \case A n; B n; C n -> n + 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment