Skip to content

Instantly share code, notes, and snippets.

@AdamSaleh
Created January 10, 2018 14:27
Show Gist options
  • Select an option

  • Save AdamSaleh/af9d80672a035b79ca35ed1211c2423b to your computer and use it in GitHub Desktop.

Select an option

Save AdamSaleh/af9d80672a035b79ca35ed1211c2423b to your computer and use it in GitHub Desktop.

by Goodacre Liam

declarations in a where clause are bound inside a given case an alternative way to do what you've written is:

nonempty = go where
  go input
    | isEmpty input = Nothing
    | otherwise = Just input

  isEmpty a = a == ""  

[3:26] that is to say, each case of a declaration can have it's own where clause:

  go input
    | isEmpty input = x
      where x = Nothing
    | otherwise = y
      where y = Just input
...

[3:26] and the variables that are bound in the pattern match are available in the where clause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment