Tidal embeds in Haskell to exploit its type system and applicative functor abstractions for pattern composition
Tidal is a DSL embedded in Haskell rather than a standalone language. This gives Tidal access to Haskell’s strong static type system, polymorphism, and type-class machinery — especially Functor and Applicative. Making Pattern an instance of Applicative enables the <*> operator, applying a pattern of functions to a pattern of values to create polyrhythmic combinations without explicit loops. Haskell’s automatic currying makes partial application terse. Trade-off: artists must learn Haskell syntax, and the GHCI interpreter adds latency. Strudel solves this by re-implementing the same pattern semantics in JavaScript for browser delivery.
Examples
Pattern is a Functor: fmap f (Pattern xs p) = Pattern (fmap (fmap (fmap f)) xs) p. (blend 0.5) <$> "red blue" <*> "white white black" — polyrhythmic colour blend.
Assessment
Explain what Haskell’s Applicative type class adds to Tidal beyond what Functor alone provides. Give an example where <*> creates a result that would require an explicit nested loop in an imperative language.