Skip to content

Instantly share code, notes, and snippets.

@onosendi
Created July 30, 2022 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onosendi/75a3d9b55c5edf5f69c6d66c5f259f3c to your computer and use it in GitHub Desktop.
Save onosendi/75a3d9b55c5edf5f69c6d66c5f259f3c to your computer and use it in GitHub Desktop.
-- data Name = Constructor1 <args> | Constructor2 <args>
data Calculation
= Add Int Int
| Sub Int Int
calc :: Calculation -> Int
calc (Add x y) = x + y
calc (Sub x y) = x - y
-- * Main> calc 1 1
-- <interactive>:76:1: error:
-- • Couldn't match expected type ‘t0 -> t’ with actual type ‘Int’
-- • The function ‘calc’ is applied to two arguments,
-- but its type ‘Calculation -> Int’ has only one
-- In the expression: calc 1 1
-- In an equation for ‘it’: it = calc 1 1
-- • Relevant bindings include it :: t (bound at <interactive>:76:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment