#2110: Rules to eliminate casted id's ---------------------------------+------------------------------------------ Reporter: igloo | Owner: Type: feature request | Status: new Priority: lowest | Milestone: 7.6.2 Component: Compiler | Version: 6.8.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------
Comment(by nomeata): Replying to [comment:19 simonpj]: > * What (precisely) is a "map-like" function, for some arbitrary data type? I'm not keen on spotting such things by somehow matching on their particular form. Remember data types can be mutually recursive, and may have several type parameters. I guess what you are not keen on is something like that: Look for a function f that returns a "T a b c", has one argument that is also a "T a b c", and all other arguments have function types. Check if f is defined by pattern match on the "T a b c" argument. Check for each constructor "C x y z", if the body for the pattern is "C (h x) (h' y) (f h h' h'' z)", where the h's are the other arguments of f, or recursive calls to f (with the same function arguments). If all this holds, generate a rule that matches on f if all the function arguments are coercions c, c', c'' and replaces it by the (existing, as I understand it) coercion "T c c' c''" applied to the non-function argument. This is not very elegant, but it would catch most hand-written maps, including Data.List.map and the fmap in the Functor instances of Maybe, Const, Either a, Id, (,) a, Digit, Node, Elem, ViewL, ViewR (judging from a quick grep over base and libraries). But I guess the question of how we expose the feature to the user, and whether GHC should also generate rules automatically if he can on a best- effort basis are two independent and orthogonal issues. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2110#comment:20> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs