Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,251
    • Issues 4,251
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 395
    • Merge Requests 395
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16030

Closed
Open
Opened Dec 11, 2018 by Ryan Scott@RyanGlScottMaintainer

Poor pretty-printing of GADT constructors in GHCi

I recently loaded this file into GHCi:

{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where

import Data.Proxy

data Foo1 (a :: k) where
  MkFoo1a :: Proxy a -> Int -> Foo1 a
  MkFoo1b :: { a :: Proxy a, b :: Int } -> Foo1 a

data family Foo2 (a :: k)
data instance Foo2 (a :: k) where
  MkFoo2a :: Proxy a -> Int -> Foo2 a
  MkFoo2b :: { c :: Proxy a, d :: Int} -> Foo2 a

And when I queried these datatypes with :info, I saw this:

$ ~/Software/ghc/inplace/bin/ghc-stage2 --interactive Bug.hs -fprint-explicit-kinds
GHCi, version 8.7.20181129: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Ok, one module loaded.
λ> :i Foo1 Foo2
type role Foo1 nominal phantom
data Foo1 @k (a :: k) where
  MkFoo1a :: forall k (a :: k). (Proxy @{k} a) -> Int -> Foo1 k a
  MkFoo1b :: forall k (a :: k).
             {a :: Proxy @{k} a, b :: Int} -> Foo1 k a
        -- Defined at Bug.hs:8:1
data family Foo2 @k (a :: k)    -- Defined at Bug.hs:12:1
data instance forall k (a :: k). Foo2 @k a where
  MkFoo2a :: forall k (a :: k). (Proxy @{k} a) -> Int -> Foo2 @k a
  MkFoo2b :: forall k (a :: k).
             {c :: Proxy @{k} a, d :: Int} -> Foo2 @k a
        -- Defined at Bug.hs:13:15

Yuck. A couple of icky things to note here:

  • For some reason, the Proxy @{k} a field is needlessly parenthesized in MkFoo1a and MkFoo2a. This does //not// happen when record syntax is used, as demonstrated with MkFoo1b and MkFoo2b.
  • Even more strangely, despite the fact that k is a specified argument, we're pretty-printing the return type of MkFoo1{a,b} as Foo k a, not Foo @k a. This problem doesn't appear to happen for data family instances, since MkFoo2{a,b} don't have this issue.

Patch incoming.

Trac metadata
Trac field Value
Version 8.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
8.8.1
Milestone
8.8.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16030