Opened 5 years ago

Last modified 4 years ago

#9394 new feature request

Show data/type family instances with ghci's :info command

Reported by: s9gf4ult Owned by: javran
Priority: normal Milestone:
Component: GHCi Version: 7.6.3
Keywords: ghci, newcomer, TypeFamilies Cc: hvr, rodlogic
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Current version of ghci (7.6.3) does not show data instances. For example, I have some Yesod application and I want to see all data constructors of (Route App) data family instance:

*Application> :info Route App 
class Eq
        (Route
           a) => yesod-routes-1.2.0.6:Yesod.Routes.Class.RenderRoute a where
  data family Route a1
  ...
        -- Defined in `yesod-routes-1.2.0.6:Yesod.Routes.Class'
instance Eq (Route App) -- Defined at Foundation.hs:48:1
instance Read (Route App) -- Defined at Foundation.hs:48:1
.................

It just shows info about Route, then info about App separately. When I try this:

*Application> :info (Route App)

<interactive>:1:2: parse error on input `Route'

I am getting parse error.

I offer to use this syntax (with parentheses) to show info about instance of data/type family, namely, data constructors and such stuff, just like for ordinal data.

Change History (10)

comment:1 Changed 5 years ago by simonpj

Dear s9gf4ult (I wonder who you are in real life?)

That makes sense. For classes, actually :info Eq lists all the instances of Eq, so maybe that should happen for type and data families too? Then adding arguments could filter the list to just the instances that match the pattern given?

Would you, or anyone else, like to specify the feature and offer a patch?

Simon

comment:2 Changed 5 years ago by s9gf4ult

Hello, Simon!

Print instances of type/data families is a great idea. I also think, that we can expand the meaning of this "parentheses syntax" to general type application. So, type application can give us four variants of data depending on "type of type" of first argument:

1) Finite typeclass application: For finite typeclass application we can print detailed information about specific instance, for example :info (Eq Int) must print assigned type/data families, module where instance is defined, maybe something else.

2) Finite data type: as application type parameters to ordinary data type with parameters. Here we can print the same as for other finite type like Int

3) Finite data family application: print information like for any other finite type, or, if type is not finite

4) Finite type family application: print type assigned to this type family.

I don't know what we must print on partial type applications in same cases, maybe just throw exception.

Unfortunately, I have no experience with GHC code base to make a patch. What do you mean about "to specify the feature" ? My English is not native...

In real life I am like a https://github.com/s9gf4ult (dont have good personal blog)

Last edited 5 years ago by s9gf4ult (previous) (diff)

comment:3 Changed 5 years ago by simonpj

OK great. Let's leave this open as a useful feature request.

Simon

comment:4 Changed 5 years ago by rodlogic

Cc: rodlogic added

comment:5 Changed 5 years ago by goldfire

Keywords: newcomer added

comment:6 Changed 5 years ago by javran

Newcomer here. I'm interested in this issue. Not sure about the difficulty, so I'll just give some of my thoughts and see if it works out.

Currently :info isn't doing a good job parsing its arguments, it simply uses words to separate arguments so that for :info (Route App), what will :info really see is two separated arguments: (Route and App).

I think the first step is to have some better handling on :info, maybe allowing it to accept a list of either names (as before) or type applications (use parentheses to disambiguate it from names).

And then we can probably leverage some type checking facilities to help filtering out instances.

comment:7 Changed 4 years ago by javran

Owner: set to javran

comment:8 Changed 4 years ago by thomie

javran: did you make any progress with this ticket? Maybe just some notes that you could contribute, such that someone else can take over? Come over to the #ghc irc channel if you need help, there are usually people around all day there.

comment:9 in reply to:  8 Changed 4 years ago by javran

Replying to thomie:

javran: did you make any progress with this ticket? Maybe just some notes that you could contribute, such that someone else can take over? Come over to the #ghc irc channel if you need help, there are usually people around all day there.

Sorry I didn't have time to contribute since I have owned this ticket. I'm just about to continue working this. Previously I sent an email to goldfire and he suggested to begin with writing up new wiki page about the plan -- will do it as a start point.

comment:10 Changed 4 years ago by thomie

Keywords: TypeFamilies added
Note: See TracTickets for help on using tickets.