I've read the arrow notation documentation page, but it's not entirely clear to me what the "pipe brackets" used under "7.10.3. Defining your own control structures" desugar into.
Given the example in the above document
proc x -> do
y <- f -< x+1
(|untilA (increment -< x+y) (within 0.5 -< x)|)
What's the equivalent code without using arrow notation?
The (| ... |)
brackets (usually called banana brackets) are for applying a function that operates on commands, inside proc notation. They are used to disambiguate a function that operates on commands (called an 'operator') from a normal command. Binary infix operators are special cased, so you don't need to write (| (&&&) x y |)
.
As for the desugaring, they're GHC's version of the form keyword from the Arrows paper.
form is defined as follows:
proc p -> form e c1 c2 ... cn
=
e (proc p -> c1) (proc p -> c2) ... (proc p -> cn)
So, proc x -> (|untilA (increment -< x+y) (within 0.5 -< x)|)
would become:
untilA (proc x -> increment -< x+y) (proc x -> within 0.5 -< x)
If you want to desugar this entirely so there is no arrow syntax left, it would become:
untilA (arr (\x -> x+y) >>> increment) (arr (\x -> x) >>> within 0.5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With