# Godwit

A compiler for a functional pattern language (based on simply-typed lambda calculus with Tidal-inspired maxi-notation syntax) to C via cartesian closed categories.

# 1 Bird

https://www.rspb.org.uk/birds-and-wildlife/black-tailed-godwit

# 2 Code

git clone https://code.mathr.co.uk/godwit.git

Very early days so far, don’t expect much.

# 3 Usage

Example pattern (needs to be all on one line):

cps (pure $ 0.18 `fmul` 1.8 `fmul` 1.8) `u`
_early (qi 18) (sound [bd*18,[~ sn]*9,[~ ht/3 mt]*6]) `u`
shape [0.8] `u`
gain [0.18] `u`
let seq = [18] `isubR` run 18
in (seq `imulL` _slow (qi 18) (seq `imulL` _slow (qi 18) seq)) `bind`
\x -> stack (map
  (\y -> let z = imod x y in ifte (igt z 0) (pure z) silence)
  (empty : 2 : 3 : 6 : 9 : 18)) `bind`
\x -> n (pure (ffromi x)) `u`
speed (flip fdiv 18.0 . ffromi . iadd (imul 18 2)
  . flip imod 18 . iadd (imul 13 x) . imul 5 $$ _slow (qi 18) seq)

Based on my Strudel looptober 2024 #18.