kmyk-jikka / Jikka

an automated solver for problems of competitive programming
https://kmyk-jikka.github.io/Jikka/playground
Apache License 2.0
152 stars 11 forks source link

rewrite rule をもっと簡単に書けるようにする #132

Closed kmyk closed 2 years ago

kmyk commented 2 years ago

GHC の RULES pragma みたいに手軽に書きたい

{-# RULES
  "map/map"    forall f g xs.  map f (map g xs) = map (f.g) xs
    #-}

Template Haskell を使って準クオートで書けるようにするのがよい気がする

mapMapReduce :: Monad m => RewriteRule m
mapMapReduce = [rule| "map/map"  forall f g xs.  map f (map g xs) = map (f.g) xs |]