edit: my new site is here: https://thaumatorium.com/
Slightly annoying that type
and class
already have a certain meaning in Haskell, but I think you’re smart enough to understand what I mean with the Title
In this context, a parser is a function accepting strings as input and returning some structure as output, typically a parse tree or a set of indices representing locations in the string where parsing stopped successfully.
Function typename | What it does | Example code |
---|---|---|
Pure | Takes an input, returns an output – no side effects (data changes) | f :: Int -> Int |
Predicate | Takes an input, returns a Bool | f :: Int -> Bool |
Recursive | Like a Pure function, but also calls itself (at least once) with a subset of the original input | length :: [a] -> Int |
Curried | You can give a function a part of the input to create a new function ( imperative languages like C or Python always want all arguments at once) | timesTwo :: Int -> Int As you can see, the * operator only has one input – It’s been partially applied! When you look at the definition, you see that timesTwo expects at least one Int, which when applied, gets added at the end of the function: timesTwo 3 |
Applicative | Can take a variable amount of inputs, returns an output | Uses a function (pure ) and an operator (<*> ), where ‘pure’ lifts the function into a wrapped type/function and ‘<*>’ accepts a wrapped type/function and a variable (that’s also wrapped) |
Monadic | Takes an input, returns an output – has side effects (data changes) and uses either the bind >>= operator or do notation | From: https://wiki.haskell.org/All_About_MonadsmaternalGrandfather :: Sheep -> Maybe Sheep |
Parser Combinator | Accepts several parsers as input and returns a new parser as its output. | From: https://en.wikipedia.org/wiki/Parser_combinator In this context, a parser is a function accepting strings as input and returning some structure as output, typically a parse tree or a set of indices representing locations in the string where parsing stopped successfully. |
edit: my new site is here: https://thaumatorium.com/