It's a good idea to expand this in future to test code as well, so we get type checking there as well.
Thanks @blitz and @jtraue for help with implementing machine methods