[GHC] #14341: Show instance for TypeReps is a bit broken

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[GHC] #14341: Show instance for TypeReps is a bit broken

GHC - devs mailing list
#14341: Show instance for TypeReps is a bit broken
-------------------------------------+-------------------------------------
           Reporter:  dfeuer         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Core           |           Version:  8.2.1
  Libraries                          |
           Keywords:  Typeable       |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):  Phab:D4084     |         Wiki Page:
-------------------------------------+-------------------------------------
 There are two problems.

 1. Showing typereps of tuples can produce unnecessary parentheses:

 {{{
 Prelude K T> typeRep @(Int, Maybe Bool)
 (Int,(Maybe Bool))
 }}}

    The fix is trivial.

 2. Showing typereps of ticked (i.e., lifted) tuples and lists gives hard-
 to-read results, because it does not use the usual special syntax:

 {{{
 Prelude K T> typeRep @'(Int, Maybe Bool)
 '(,) * * Int (Maybe Bool)

 Prelude K T> typeRep @'[1,2,3]
 ': Nat 1 (': Nat 2 (': Nat 3 ('[] Nat)))
 }}}

    Fixing the lifted tuple case is trivial. Fixing the lifted list case is
 slightly less trivial, but not hard.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14341>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14341: Show instance for TypeReps is a bit broken

GHC - devs mailing list
#14341: Show instance for TypeReps is a bit broken
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Core Libraries    |              Version:  8.2.1
      Resolution:                    |             Keywords:  Typeable
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4084
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 Actually, there's a third problem as well: type operators are not shown
 infix! The solution, I believe, is to add operator precedence to `TyCon`,
 and then to use something akin to `Show` derivation machinery in
 `showTypeRep`. I imagine we don't need to worry too much about showing
 these things ''efficiently'', at least for the foreseeable future.
 `SomeTypeRep` has no `Read` instance, so there's no substantial risk of
 anyone trying to use its `Show` instance for anything other than error
 messages and interactive exploration.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14341#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14341: Show instance for TypeReps is a bit broken

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14341: Show instance for TypeReps is a bit broken
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Core Libraries    |              Version:  8.2.1
      Resolution:                    |             Keywords:  Typeable
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4084
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by dfeuer:

Old description:

> There are two problems.
>
> 1. Showing typereps of tuples can produce unnecessary parentheses:
>
> {{{
> Prelude K T> typeRep @(Int, Maybe Bool)
> (Int,(Maybe Bool))
> }}}
>
>    The fix is trivial.
>
> 2. Showing typereps of ticked (i.e., lifted) tuples and lists gives hard-
> to-read results, because it does not use the usual special syntax:
>
> {{{
> Prelude K T> typeRep @'(Int, Maybe Bool)
> '(,) * * Int (Maybe Bool)
>
> Prelude K T> typeRep @'[1,2,3]
> ': Nat 1 (': Nat 2 (': Nat 3 ('[] Nat)))
> }}}
>
>    Fixing the lifted tuple case is trivial. Fixing the lifted list case
> is slightly less trivial, but not hard.
New description:

 There are three problems.

 1. Showing typereps of tuples can produce unnecessary parentheses:

 {{{
 Prelude K T> typeRep @(Int, Maybe Bool)
 (Int,(Maybe Bool))
 }}}

    The fix is trivial.

 2. Showing typereps of ticked (i.e., lifted) tuples and lists gives hard-
 to-read results, because it does not use the usual special syntax:

 {{{
 Prelude K T> typeRep @'(Int, Maybe Bool)
 '(,) * * Int (Maybe Bool)

 Prelude K T> typeRep @'[1,2,3]
 ': Nat 1 (': Nat 2 (': Nat 3 ('[] Nat)))
 }}}

    Fixing the lifted tuple case is trivial. Fixing the lifted list case is
 slightly less trivial, but not hard.

 3. Type operator applications are not shown infix.

 {{{
 Prelude K T> typeRep @(Maybe :*: Either Int)
 :*: * Maybe (Either Int)
 }}}

 This is the hardest problem to fix, although it's probably not too
 terribly hard. See comment:1 for thoughts.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14341#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets