User Tools

Site Tools


codesnippets:letandwhereconstructs

Let and where constructs

Hard differences

Inside expression

  • let constructs are legal
    • example code:
      main = print (1 + (let i = 10 in 2 * i + 1))
  • where constructs are ilegal
    • example code:
      main = print (1 + (2 * i + 1 where i = 10))

Function that use functions

  • where constructs are legal
    • example code:
      hasVowel [] = False
      hasVowel (x:xs)
        | x `elem` vowels = True
        | otherwise = False
        where vowels = "AEIOUaeiou"
  • let constructs are ilegal
    • example code:
      let vowels = "AEIOUaeiou"
      in hasVowel = ...

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
You could leave a comment if you were logged in.
codesnippets/letandwhereconstructs.txt · Last modified: by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki