lambdageek / unbound-generics

Specify variable binding in syntax trees using GHC.Generics (reimplementation of Unbound)
https://hackage.haskell.org/package/unbound-generics/
BSD 3-Clause "New" or "Revised" License
55 stars 18 forks source link

Cherrypick `instantiate` from sweirich's branch #48

Closed lambdageek closed 2 years ago

lambdageek commented 2 years ago

See https://github.com/lambdageek/unbound-generics/issues/16#issuecomment-1164647287

Pickup the new instantiate function:

-- | Immediately substitute for the bound variables of a pattern
-- in a binder, without first naming the variables.
-- NOTE: this operation does not check that the number of terms passed in 
-- match the number of variables in the pattern. (Or that they are of appropriate type.)
instantiate :: (Alpha a, Alpha b, Alpha p, Subst a b) => Bind p b -> [a] -> b
lambdageek commented 2 years ago

We should do this before releasing a package on Hackage with substPat exposed, since instantiate replaces it with a more general substBvs.