4 ms·
Don't just hope, write it yourself! {-# RULES "filter/filter" forall f g xs. filter f (filter g xs) = filter (f.g) xs #-} It's a programmable program
by lsb 16y ago
Don't just hope, write it yourself!
{-# RULES
"filter/filter" forall f g xs. filter f (filter g xs) = filter (f.g) xs
#-}
It's a programmable programming language.
- ced 16y agoNice. What's the limit on what you can do with these RULES? Could you extend the language? Write a DSL? Implement a mini-prolog à la On Lisp?
- jrockway 16y agoYou can do a lot of weird stuff, but it's not the right place for that. Just use Template Haskell.
- uros643 16y agoDon't you mean forall f g xs. map f (map g xs) = map (f.g) xs ? As for filter, I presume something like forall f g xs. filter f (filter g xs) = filter (\x. g x && f x) xs would work.
- lsb 16y agoYup, forall f g xs . filter f (filter g xs) = filter (\x -> g x && f x) xs was exactly what I meant, thanks for the catch!