summaryrefslogtreecommitdiff
path: root/testsuite/tests/roles
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-06-03 14:15:52 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-06-03 14:24:08 +0100
commitb4856f9f4f0fb3db473901b247d3fa94a11c25a0 (patch)
tree64512fff57acca9baf54d0e72d516679763711a9 /testsuite/tests/roles
parentda64c97f1c0b147ea80a34fe64fe947ba7820c00 (diff)
downloadhaskell-b4856f9f4f0fb3db473901b247d3fa94a11c25a0.tar.gz
Do pretty-printing of TyThings via IfaceDecl (Trac #7730)
All the initial work on this was done fy 'archblob' (fcsernik@gmail.com); thank you! I reviewed the patch, started some tidying, up and then ended up in a huge swamp of changes, not all of which I can remember now. But: * To suppress kind arguments when we have -fno-print-explicit-kinds, - IfaceTyConApp argument types are in a tagged list IfaceTcArgs * To allow overloaded types to be printed with =>, add IfaceDFunTy to IfaceType. * When printing data/type family instances for the user, I've made them print out an informative RHS, which is a new feature. Thus ghci> info T data family T a data instance T Int = T1 Int Int data instance T Bool = T2 * In implementation terms, pprIfaceDecl has just one "context" argument, of type IfaceSyn.ShowSub, which says - How to print the binders of the decl see note [Printing IfaceDecl binders] in IfaceSyn - Which sub-comoponents (eg constructors) to print * Moved FastStringEnv from RnEnv to OccName It all took a ridiculously long time to do. But it's done!
Diffstat (limited to 'testsuite/tests/roles')
-rw-r--r--testsuite/tests/roles/should_compile/Roles1.stderr64
-rw-r--r--testsuite/tests/roles/should_compile/Roles14.stderr6
-rw-r--r--testsuite/tests/roles/should_compile/Roles2.stderr16
-rw-r--r--testsuite/tests/roles/should_compile/Roles3.stderr29
-rw-r--r--testsuite/tests/roles/should_compile/Roles4.stderr11
-rw-r--r--testsuite/tests/roles/should_compile/T8958.stderr89
-rw-r--r--testsuite/tests/roles/should_fail/Roles12.stderr2
7 files changed, 69 insertions, 148 deletions
diff --git a/testsuite/tests/roles/should_compile/Roles1.stderr b/testsuite/tests/roles/should_compile/Roles1.stderr
index de4ecf36e2..96d5603bbf 100644
--- a/testsuite/tests/roles/should_compile/Roles1.stderr
+++ b/testsuite/tests/roles/should_compile/Roles1.stderr
@@ -1,54 +1,20 @@
TYPE SIGNATURES
TYPE CONSTRUCTORS
- T1 :: * -> *
- data T1 a
- No C type associated
- Roles: [nominal]
- RecFlag NonRecursive, Promotable
- = K1 :: forall a. a -> T1 a Stricts: _
- FamilyInstance: none
- T2 :: * -> *
- data T2 a
- No C type associated
- Roles: [representational]
- RecFlag NonRecursive, Promotable
- = K2 :: forall a. a -> T2 a Stricts: _
- FamilyInstance: none
- T3 :: forall (k :: BOX). k -> *
- data T3 (k::BOX) (a::k)
- No C type associated
- Roles: [nominal, phantom]
- RecFlag NonRecursive, Not promotable
- = K3 :: forall (k::BOX) (a::k). T3 k a
- FamilyInstance: none
- T4 :: (* -> *) -> * -> *
- data T4 (a::* -> *) b
- No C type associated
- Roles: [nominal, nominal]
- RecFlag NonRecursive, Not promotable
- = K4 :: forall (a::* -> *) b. (a b) -> T4 a b Stricts: _
- FamilyInstance: none
- T5 :: * -> *
- data T5 a
- No C type associated
- Roles: [representational]
- RecFlag NonRecursive, Promotable
- = K5 :: forall a. a -> T5 a Stricts: _
- FamilyInstance: none
- T6 :: forall (k :: BOX). k -> *
- data T6 (k::BOX) (a::k)
- No C type associated
- Roles: [nominal, phantom]
- RecFlag NonRecursive, Not promotable
- = K6 :: forall (k::BOX) (a::k). T6 k a
- FamilyInstance: none
- T7 :: forall (k :: BOX). k -> * -> *
- data T7 (k::BOX) (a::k) b
- No C type associated
- Roles: [nominal, phantom, representational]
- RecFlag NonRecursive, Not promotable
- = K7 :: forall (k::BOX) (a::k) b. b -> T7 k a b Stricts: _
- FamilyInstance: none
+ type role T1 nominal
+ data T1 a = K1 a
+ Promotable
+ data T2 a = K2 a
+ Promotable
+ type role T3 phantom
+ data T3 (a :: k) = K3
+ type role T4 nominal nominal
+ data T4 (a :: * -> *) b = K4 (a b)
+ data T5 a = K5 a
+ Promotable
+ type role T6 phantom
+ data T6 (a :: k) = K6
+ type role T7 phantom representational
+ data T7 (a :: k) b = K7 b
COERCION AXIOMS
Dependent modules: []
Dependent packages: [base, ghc-prim, integer-gmp]
diff --git a/testsuite/tests/roles/should_compile/Roles14.stderr b/testsuite/tests/roles/should_compile/Roles14.stderr
index 13231931e3..e0f26a14d3 100644
--- a/testsuite/tests/roles/should_compile/Roles14.stderr
+++ b/testsuite/tests/roles/should_compile/Roles14.stderr
@@ -1,9 +1,7 @@
TYPE SIGNATURES
TYPE CONSTRUCTORS
- C2 :: * -> Constraint
- class C2 a
- Roles: [representational]
- RecFlag NonRecursive
+ type role C2 representational
+ class C2 a where
meth2 :: a -> a
COERCION AXIOMS
axiom Roles12.NTCo:C2 :: C2 a = a -> a
diff --git a/testsuite/tests/roles/should_compile/Roles2.stderr b/testsuite/tests/roles/should_compile/Roles2.stderr
index f5bcbe6829..e6f9bcd8d0 100644
--- a/testsuite/tests/roles/should_compile/Roles2.stderr
+++ b/testsuite/tests/roles/should_compile/Roles2.stderr
@@ -1,19 +1,7 @@
TYPE SIGNATURES
TYPE CONSTRUCTORS
- T1 :: * -> *
- data T1 a
- No C type associated
- Roles: [representational]
- RecFlag NonRecursive, Not promotable
- = K1 :: forall a. (IO a) -> T1 a Stricts: _
- FamilyInstance: none
- T2 :: * -> *
- data T2 a
- No C type associated
- Roles: [representational]
- RecFlag NonRecursive, Not promotable
- = K2 :: forall a. (FunPtr a) -> T2 a Stricts: _
- FamilyInstance: none
+ data T1 a = K1 (IO a)
+ data T2 a = K2 (FunPtr a)
COERCION AXIOMS
Dependent modules: []
Dependent packages: [base, ghc-prim, integer-gmp]
diff --git a/testsuite/tests/roles/should_compile/Roles3.stderr b/testsuite/tests/roles/should_compile/Roles3.stderr
index 62eb2a9474..270afca9cd 100644
--- a/testsuite/tests/roles/should_compile/Roles3.stderr
+++ b/testsuite/tests/roles/should_compile/Roles3.stderr
@@ -1,31 +1,16 @@
TYPE SIGNATURES
TYPE CONSTRUCTORS
- C1 :: * -> Constraint
- class C1 a
- Roles: [nominal]
- RecFlag NonRecursive
+ class C1 a where
meth1 :: a -> a
- C2 :: * -> * -> Constraint
- class C2 a b
- Roles: [nominal, nominal]
- RecFlag NonRecursive
- meth2 :: (~) * a b -> a -> b
- C3 :: * -> * -> Constraint
- class C3 a b
- Roles: [nominal, nominal]
- RecFlag NonRecursive
- type family F3 b :: * (open)
+ class C2 a b where
+ meth2 :: a ~ b => a -> b
+ class C3 a b where
+ type family F3 b :: * open
meth3 :: a -> F3 b -> F3 b
- C4 :: * -> * -> Constraint
- class C4 a b
- Roles: [nominal, nominal]
- RecFlag NonRecursive
+ class C4 a b where
meth4 :: a -> F4 b -> F4 b
- F4 :: * -> *
- type family F4 a :: * (open)
- Syn1 :: * -> *
+ type family F4 a :: * open
type Syn1 a = F4 a
- Syn2 :: * -> *
type Syn2 a = [a]
COERCION AXIOMS
axiom Roles3.NTCo:C1 :: C1 a = a -> a
diff --git a/testsuite/tests/roles/should_compile/Roles4.stderr b/testsuite/tests/roles/should_compile/Roles4.stderr
index 32862ea073..f2b590fadd 100644
--- a/testsuite/tests/roles/should_compile/Roles4.stderr
+++ b/testsuite/tests/roles/should_compile/Roles4.stderr
@@ -1,16 +1,9 @@
TYPE SIGNATURES
TYPE CONSTRUCTORS
- C1 :: * -> Constraint
- class C1 a
- Roles: [nominal]
- RecFlag NonRecursive
+ class C1 a where
meth1 :: a -> a
- C3 :: * -> Constraint
- class C3 a
- Roles: [nominal]
- RecFlag NonRecursive
+ class C3 a where
meth3 :: a -> Syn1 a
- Syn1 :: * -> *
type Syn1 a = [a]
COERCION AXIOMS
axiom Roles4.NTCo:C1 :: C1 a = a -> a
diff --git a/testsuite/tests/roles/should_compile/T8958.stderr b/testsuite/tests/roles/should_compile/T8958.stderr
index 919530bb03..d400b9190c 100644
--- a/testsuite/tests/roles/should_compile/T8958.stderr
+++ b/testsuite/tests/roles/should_compile/T8958.stderr
@@ -1,49 +1,40 @@
-
-T8958.hs:1:31: Warning:
- -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
-TYPE SIGNATURES
-TYPE CONSTRUCTORS
- Map :: * -> * -> *
- newtype (Nominal k, Representational v) => Map k v
- No C type associated
- Roles: [nominal, representational]
- RecFlag NonRecursive, Promotable
- = MkMap :: [(k, v)] -> Map k v Stricts: _
- FamilyInstance: none
- Nominal :: * -> Constraint
- class Nominal a
- Roles: [nominal]
- RecFlag NonRecursive
- Representational :: * -> Constraint
- class Representational a
- Roles: [representational]
- RecFlag NonRecursive
-COERCION AXIOMS
- axiom T8958.NTCo:Map :: Map k v = [(k, v)]
-INSTANCES
- instance [incoherent] Representational a
- -- Defined at T8958.hs:10:10
- instance [incoherent] Nominal a -- Defined at T8958.hs:7:10
-Dependent modules: []
-Dependent packages: [base, ghc-prim, integer-gmp]
-
-==================== Typechecker ====================
-AbsBinds [a] []
- {Exports: [T8958.$fRepresentationala <= $dRepresentational
- <>]
- Exported types: T8958.$fRepresentationala [InlPrag=[ALWAYS] CONLIKE]
- :: forall a. Representational a
- [LclIdX[DFunId],
- Str=DmdType,
- Unf=DFun: \ (@ a) -> T8958.D:Representational TYPE a]
- Binds: $dRepresentational = T8958.D:Representational}
-AbsBinds [a] []
- {Exports: [T8958.$fNominala <= $dNominal
- <>]
- Exported types: T8958.$fNominala [InlPrag=[ALWAYS] CONLIKE]
- :: forall a. Nominal a
- [LclIdX[DFunId],
- Str=DmdType,
- Unf=DFun: \ (@ a) -> T8958.D:Nominal TYPE a]
- Binds: $dNominal = T8958.D:Nominal}
-
+
+T8958.hs:1:31: Warning:
+ -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
+TYPE SIGNATURES
+TYPE CONSTRUCTORS
+ type role Map nominal representational
+ newtype (Nominal k, Representational v) => Map k v = MkMap [(k, v)]
+ Promotable
+ class Nominal a
+ type role Representational representational
+ class Representational a
+COERCION AXIOMS
+ axiom T8958.NTCo:Map :: Map k v = [(k, v)]
+INSTANCES
+ instance [incoherent] Representational a
+ -- Defined at T8958.hs:10:10
+ instance [incoherent] Nominal a -- Defined at T8958.hs:7:10
+Dependent modules: []
+Dependent packages: [base, ghc-prim, integer-gmp]
+
+==================== Typechecker ====================
+AbsBinds [a] []
+ {Exports: [T8958.$fRepresentationala <= $dRepresentational
+ <>]
+ Exported types: T8958.$fRepresentationala [InlPrag=[ALWAYS] CONLIKE]
+ :: forall a. Representational a
+ [LclIdX[DFunId],
+ Str=DmdType,
+ Unf=DFun: \ (@ a) -> T8958.D:Representational TYPE a]
+ Binds: $dRepresentational = T8958.D:Representational}
+AbsBinds [a] []
+ {Exports: [T8958.$fNominala <= $dNominal
+ <>]
+ Exported types: T8958.$fNominala [InlPrag=[ALWAYS] CONLIKE]
+ :: forall a. Nominal a
+ [LclIdX[DFunId],
+ Str=DmdType,
+ Unf=DFun: \ (@ a) -> T8958.D:Nominal TYPE a]
+ Binds: $dNominal = T8958.D:Nominal}
+
diff --git a/testsuite/tests/roles/should_fail/Roles12.stderr b/testsuite/tests/roles/should_fail/Roles12.stderr
index bb830beae3..9b0f2cfdb5 100644
--- a/testsuite/tests/roles/should_fail/Roles12.stderr
+++ b/testsuite/tests/roles/should_fail/Roles12.stderr
@@ -4,4 +4,4 @@ Roles12.hs:5:1:
and its hs-boot file
Main module: type role T phantom
data T a
- Boot file: data T a
+ Boot file: abstract T a