Reverse AND transpose using `off`?

Hello there! I am new to both Tidal and Haskell, but very excited by what I've learned so far.

I am attempting to use the off function to offset a pattern. I would also like to transpose the offset version AND reverse it. For example, here, I transpose the offset:

d1
    $ off 0.25 (|+ n "12")
    $ n "c e g b" # s "supervibe"

... and here I reverse it:

d1
    $ off 0.25 (rev)
    $ n "c e g b" # s "supervibe"

I can't seem to do both simultaneously, however. With other functions, I know I can do something like this:

d1
    $ off 0.25 (jux rev)
    $ n "c e g b" # s "supervibe"

... but with the |+ in play, I can't figure out how I'd chain together the transposing and the rev.

Thanks!
Matt.

1 Like
d1
    $ off 0.25 (rev.(|+ 12))
    $ n "c e g b" # s "supervibe"

Does this have the effect you want? If so, the dot operator in Haskell let's you make new functions by chaining other functions together. By putting dot between rev and + we make a new function that does both - on right after the other.

Secondary to the point at hand, and merely since I happened to notice it while reading:

Try to make a habit of always placing whitespace around the composition operator . ala:

(rev . (|+ 12))

If at some point one finds themselves working in other Haskell codebases (or even when Tidalling, potentially) then that symbol, without space on each side, can have a different meaning.

whitespace around the composition operator .

source: "When OverloadedRecordDot is enabled one can write a.b to mean the b field of the a record expression."
https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/overloaded_record_dot.html

while we're at it, recent GHCs introduced whitespace sensitivity around ~, !, and @, see 16. Known bugs and infelicities — Glasgow Haskell Compiler 9.8.1 User's Guide .

I found these more surprising since they are active by default, while the record selector thing is hidden behind an language flag. - Which might become the default later down the road, so the advice here is sound.

1 Like

Thanks for adding reference info, @jwaldmann! Next time I’ll finish my replying job properly, I promise. :slight_smile:

There is also a long explanation of the . operator in the docs: The meaning of . | Tidal Cycles

1 Like

OK, can't resist. Quoting that page (a fine page, and it does apply whitespace-around-dot as recommended),

Function composition comes from mathematics but actually, it can be really useful ...

I would replace "but actually it can be" with "and therefore it is" ...

2 Likes

Thanks so much for the . solution; it does indeed address my issue. Thanks also for the additional reference/discussion/nerdery :slight_smile:

1 Like

@jwaldmann Thanks!
Requested change made. It now reads:
Function composition comes from mathematics - therefore it is really useful in making music.
The role of mathematics has been restored. :wink:

@jwaldmann, @mvdirty. Good to know! I'm new at Haskell and have not yet had the opportunity of encountering the other meaning of dot.

@xinniw This is way off topic here, but I wanted to say that I really enjoyed your Solstice stream. Very cool use of what sounded like granular glitch. Your advanced use of cycle subdivisions and variety of pattern groupings is really amazing. Lots to learn from.

Others can check it out here: Solstice Night Stream December 2022 - xinniw - 2022-12-21 16:00 - YouTube

1 Like