I was reading this interesting post for the hundredth time and I am still trying to understand what's behind the different instances of
Pattern and especially when it is useful to handle
Functor Pattern and
Here is what I got so far:
Functor Patterncomes handy when we want to use function from e.g. the standard
Preludemodule but we don't know how to cope with the
Patterncontext. We use
<$>and we get a result wrapped in a
Patterncontext that we can use inside Tidal.
chop (round <$> (slow 8 $ range 1 128 $ sine))- thanks @nuelmyr for the pattern
Monad Patterncomes handy when we have a function that returns a
Patterncontext, but it does not accept a value in a context. We use
Monad Patternwill apply the function to the
Patternand we get a result wrapped in a
I think the example from the post is quite explicative:
fastFromList[False,False,True] >>= \ f -> if not f then run 2 else run 3
But what about
Applicative Pattern: what is a pattern of functions (
Pattern (a -> b))?
I am very interested in seeing some examples on how you use the different instances of
Pattern to create your own functions.