resource monad in compilation WIP