Note that the following paragraphs will only show one of many ways to specify a sequential circuit, at the section we will show a … but instead I find no canonical implementation of it anywhere, and what seems like a useless instance Alternative [] . Sometimes in Haskell programs, function definitions will span multiple lines and consist of multiple elements. If a line is indented less, then the previous line is the last alternative in the case statement. If a line is indented more, then it is a continuation of the previous line. coalesce a b = if null a then b else a I expected this to be (<|>) (it is for Maybe !) This is another example of whitespace sensitive layout in Haskell. For example, suppose that we have a stream of basic tokens tupled with source positions. This chapter will cover some of Haskell's cool syntactic constructs and we'll start with pattern matching. 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 Sure, there are several choices at hand! * A switch statement. 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. 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. 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. Haskell's … Like with the do statement, each alternative of the case statement will be indented the same amount. Pattern matching consists of specifying patterns to which some data should conform and then checking to see if it does … 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. Syntax in Functions 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