Skip to content

Instantly share code, notes, and snippets.

@wimvanderbauwhede
Last active December 13, 2021 14:06
Show Gist options
  • Save wimvanderbauwhede/f2ac295b2a607556de580bf105caac5c to your computer and use it in GitHub Desktop.
Save wimvanderbauwhede/f2ac295b2a607556de580bf105caac5c to your computer and use it in GitHub Desktop.
# Any expression in the language
role Expr {}
# map f v
role MapV[Expr \f_,Expr \v_] does Expr {
    has Expr $.f = f_;
    has Expr $.v = v_;
}
# function composition f . g
role Comp[Expr \f_, Expr \g_] does Expr {
    has Expr $.f = f_;
    has Expr $.g = g_;
}
# zipt t turns a tuple of vectors into a vector of tuples
role ZipT[Expr \t_] does Expr {
    has Expr $.t = t_
}
# tuples are just arrays of Expr
role Tuple[Array[Expr] \e_] does Expr {
    has Array[Expr] $.e = e_
}
# names of functions and vectors are just string constants
role Name[Str \n_] does Expr {
    has Str $.n = n_
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment