Int -> Int plus a b = x...">

Haskell. Where with two definitions

Can I use two "where" with two or more blocks? Something like that:

plus:: Int -> Int -> Int
plus a b = x + y
         where x = f1 a
         where y = f2 b
+3
source share
1 answer

Leave all but the first where:

plus:: Int -> Int -> Int
plus a b = x + y
         where x = f1 a
               y = f2 b

note that

  • definitions must match
  • you should backtrack only with spaces and not behind tabs (some text editors do not use the standard tab tab width driven by ghc to assume that the last line is indented further or less than it actually is; error)
+15
source

All Articles