# 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 Uzulang
Godwit is an Uzulang. An Uzulang is a member of a family of languages in the style of TidalCycles. Other Uzulangs are available.
# 3 Code
git clone https://code.mathr.co.uk/godwit.git
Very early days so far, don’t expect much.
# 4 Bootstrap
This is a script I use to install/update Godwit using MicroHs (a Haskell compiler that is much smaller than GHC, and more up to date than Hugs). It fetches the latest MicroHs, dependencies of Godwit, and Godwit itself, and rebuilds it all if the fetched version is newer than the currently installed MicroHs.
Currently needs alex
and happy
parser generation tools.
The script has some bugs re git stash
(might pop an old one…).
Download: bootstrap.sh.
#!/bin/sh
set -ev
FORCE="${1}"
OLD="$(mhs --numeric-version || echo none)"
( git clone https://github.com/augustss/MicroHs.git || (cd MicroHs && git stash && git pull && (git stash pop || true)) )
( git clone https://github.com/augustss/mtl.git || (cd mtl && git stash && git pull && (git stash pop || true)) )
( git clone https://github.com/haskell/containers.git || (cd containers && git stash && git pull && (git stash pop || true)) )
( git clone https://code.mathr.co.uk/godwit.git || (cd godwit && git stash && git pull && (git stash pop || true)) )
NEW="$(grep '^version:' MicroHs/MicroHs.cabal | sed -e 's/^version: *//')"
if [ "x$OLD" != "x$NEW" -o "x$FORCE" = "x--force" ]
then
rm -rf "${HOME}/.mcabal/mhs-$OLD"
( cd MicroHs && make clean && make install )
PATH="${HOME}/.mcabal/bin:${PATH}"
( mcabal install transformers )
( cd mtl && mcabal install )
( cd containers/containers && mcabal install )
( cd godwit && make HC=mhs clean && make HC=mhs -j "$(nproc)" )
fi
# 5 Download
If you don’t have alex
or happy
,
and don’t plan on editing the parser definition,
you can download a snapshot
which includes pre-generated Parser.hs
and Lexer.hs
:
- godwit-0.tgz (2025-07-13)
Future versions of godwit will
abandon alex
and happy
(which work with GHC only)
in favour of parsec
, which is much more portable.
You still need the other Haskell dependencies
(transformers
, mtl
, containers
)
(see bootstrap script above for installation with MicroHs).
# 6 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.
# 7 Legal
Copyright (C) 2024-2025 Claude Heiland-Allen
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.