Is it possible to use an arbitrary test function to decide whether or not to apply another function? For example, to determine if a MIDI control pattern satisfies some condition?:
-- test if midi control input #64 is greater than 0.3
-- if true, then apply `rev`
d1 $ ifArbitrary ((> 0.3) . (cF 0 "64")) rev $ s "bd drum*3 odx future*4"
-- or more plainly:
d1 $ ifArbitrary ((> 0.3) . ("0.1 0.7 0.6 0.2")) rev $ s "bd drum*3 odx future*4"
Apologies for my invalid Haskell. Hopefully the question makes sense.
While I personally don’t use it as often, don’t forget it’s relative <&> if you prefer how the following reads:
d1 $ while ((cF 0 "64") <&> (> 0.3)) rev $ s "bd drum*3 odx future*4"
It might also allow the dropping of some parens (though I’m away from my computer to double-check that)
d1 $ while (cF 0 "64" <&> (> 0.3)) rev $ s "bd drum*3 odx future*4"
In essence, <&> is to <$> as for is to fmap, and sometimes the latter pair will type/read better too, especially during partial application.
If you do this kind of thing a lot, you could probably go wild creating custom infix functions like <&<>, <&<=>, <&>>, <&>=>, and so on and remove yet more parens.