| 1 | {-# LANGUAGE GADTs, KindSignatures, DataKinds, FlexibleInstances #-} |
|---|
| 2 | |
|---|
| 3 | import Data.Thrist -- cabal install thrist-0.3 |
|---|
| 4 | |
|---|
| 5 | data Nat = Zt | St Nat |
|---|
| 6 | |
|---|
| 7 | data At :: * -> Nat -> Nat -> * where |
|---|
| 8 | HoldChar :: Char -> At Char n (St n) |
|---|
| 9 | |
|---|
| 10 | instance Show (Thrist (At Char) m n) where |
|---|
| 11 | show t = '"' : go t ('"':[]) |
|---|
| 12 | where -- go :: Thrist (At Char) m' n' -> String -> String |
|---|
| 13 | go Nil acc = acc |
|---|
| 14 | go (Cons (HoldChar c) rest) acc = c : go rest acc |
|---|
| 15 | |
|---|
| 16 | {- |
|---|
| 17 | |
|---|
| 18 | Results in: |
|---|
| 19 | |
|---|
| 20 | ghc: panic! (the 'impossible' happened) |
|---|
| 21 | (GHC version 7.7.20121114 for x86_64-unknown-linux): |
|---|
| 22 | tcTyVarDetails |
|---|
| 23 | <<details unavailable>> |
|---|
| 24 | |
|---|
| 25 | Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | When the type declaration of 'go' is present, |
|---|
| 29 | this compiles. |
|---|
| 30 | |
|---|
| 31 | -} |
|---|