[GHC] #12895: Lookup rules associated with functions/values in GHCI

#12895: Lookup rules associated with functions/values in GHCI -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- It would be nice to have a way to look up in GHCi what rules can fire for a certain constant as the outmost symbol on the LHS. For example, something like {{{ ghci> :pragmas map {-# RULE "map" [~1] forall f xs. map f xs = build (\c n -> foldr (mapFB c f) n xs) #-} {-# RULE "map/coerce" [1] map coerce = coerce #-} }}} As the name suggests, I think we would also want to list applicable NOINLINE, INLINE, INLINABLE, CONLIKE, SPECIALIZE, etc pragmas too. This would simplify the process of debugging mis-firing rules. If this isn't too difficult, I'd love to try implementing it. I've been looking for some way of contributing to GHC. This initially came up here http://stackoverflow.com/q/38651602/3072788. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12895 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12895: Lookup rules associated with functions/values in GHCI -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I can see the value, and I don't think it'd be hard. Happy to advise. First look at how `:info` works, I suggest. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12895#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12895: Lookup rules associated with functions/values in GHCI -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by harpocrates): Replying to [comment:1 simonpj]:
I can see the value, and I don't think it'd be hard. Happy to advise.
First look at how `:info` works, I suggest.
Simon
After a quick survey of how `:info` works, I think I'm starting to see what needs to be done (or getting lost). As `:info` does for finding instances, I'll need to start by loading some interfaces to make sure I really do find all my `RULES`, then I should be able to get out of the `ExternalPackageState` a `RuleBase`, at which point I just need to filter for the right `CoreRule`s . However, is `CoreRule` really the abstraction I'm looking for? I noticed there is also an interface level `IfaceRule` and a type checker level `LRuleDecl Id` (from `TcGblEnv`) so I thought I'd ask... More generally, how little of this sounds right? :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12895#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12895: Lookup rules associated with functions/values in GHCI -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Sounds about right. You should think of `IfaceSyn` as simply a tree full of strings that is the result of parsing the bits in an interface file. It's not suitable for anythingn except printing. `TcIface` converts `IfaceSyn` to `CoreSyn`, `CoreRule`, `TyCon` etc. I suggest you work with `CoreRules`. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12895#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC