VictorCMiraldo / hdiff

Hash-based Diffing for AST's
MIT License
75 stars 3 forks source link

Optimize treefix operations #17

Open VictorCMiraldo opened 5 years ago

VictorCMiraldo commented 5 years ago

It is very common to ues code such as:

... $ utxMap f $ utxLCP p q

which can be fused with a better utxLCPWith:

... $ utxLCPWith f p q

utxLCPWith :: (forall at . UTx phi at -> UTx psi at -> res at)
                   -> UTx phi at -> UTx psi at -> UTx res at

utxLCP = utxLCPWith (:*:)

Another pattern we can optimize is the

... $ foldr f e $ utxGetHolesWith' g p
VictorCMiraldo commented 5 years ago

Another pattern I use a lot:

... $ utxGetHolesWith' f $ utxLCP p q