If a line is indented more, then it is a continuation of the previous line. Sure, there are several choices at hand! This chapter will cover some of Haskell's cool syntactic constructs and we'll start with pattern matching. Haskell Code: for loop: forLoop :: Int - Int - Int - Int forLoop loopNr maxLoopNr value = if loopNr "less then" 10 then forLoop (loopNr + 1) maxLoopNr (3 + loopNr) else value This is another example of whitespace sensitive layout in Haskell. * A switch statement. This only works for equality comparisons (the === operator in JavaScript). Pattern matching provides a way to "dispatch control" based on structural properties of a value. Sometimes in Haskell programs, function definitions will span multiple lines and consist of multiple elements. but instead I find no canonical implementation of it anywhere, and what seems like a useless instance Alternative [] . We can then define a parser that accepts single tokens as: mytoken x = token showTok posFromTok testTok where showTok (pos,t) = show t posFromTok (pos,t) = pos testTok (pos,t) = if x == t then Just t else Nothing Pattern matching consists of specifying patterns to which some data should conform and then checking to see if it does … Like with the do statement, each alternative of the case statement will be indented the same amount. For example, suppose that we have a stream of basic tokens tupled with source positions. The register function is our primary sequential building block to capture state.It is used internally by one of the CLaSH.Prelude function that we will use to describe our MAC circuit. Factorial by primitive recursion on decreasing num > fac1 :: Int -> Int > fac1 n = if n==1 then 1 else (n * fac1 (n-1)) Make an "adder" from an Int > mkAdder n = addN where addN m = n+m > add7 = mkAdder 7 The offside rule. In many circumstances we don't wish to define a function every time we need to do this, but so far we have only shown how to do pattern matching in function definitions. If a line is indented less, then the previous line is the last alternative in the case statement. Haskell's … Syntax in Functions Pattern matching. Note that the following paragraphs will only show one of many ways to specify a sequential circuit, at the section we will show a … coalesce a b = if null a then b else a I expected this to be (<|>) (it is for Maybe !)