From a6e36fc8cde675c2b7b2bc8f519221c93f20f207 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 31 Mar 2014 20:02:36 +0200 Subject: Crash when exporting record selectors of data family instances This fixes bug #294. This also fixes a related but never-before-mentioned bug about the display of GADT record selectors with non-polymorphic type signatures. Note: Associated data type constructors fail to show up if nothing is exported that they could be attached to. Exporting any of the data types in the instance head, or the class + data family itself, causes them to show up, but in the absence of either of these, exporting just the associated data type with the constructor itself will result in it being hidden. The only scenario I can come up that would involve this kind of situation involved OverlappingInstances, and even then it can be mitigated by just exporting the class itself, so I'm not going to solve it since the logic would most likely be very complicated. --- html-test/ref/Bug294.html | 165 ++++++++++++++++++++++++++++++++++++++++++++++ html-test/src/Bug294.hs | 37 +++++++++++ 2 files changed, 202 insertions(+) create mode 100644 html-test/ref/Bug294.html create mode 100644 html-test/src/Bug294.hs (limited to 'html-test') diff --git a/html-test/ref/Bug294.html b/html-test/ref/Bug294.html new file mode 100644 index 00000000..ceae2932 --- /dev/null +++ b/html-test/ref/Bug294.html @@ -0,0 +1,165 @@ + +Bug294

 

Safe HaskellSafe-Inferred

Bug294

Documentation

data A

Instances

data DP A = ProblemCtor' A 
data TP A = ProblemCtor A 

problemField :: TO A -> A

problemField' :: DO A -> A

gadtField :: GADT A -> A

data family DP t :: *

Instances

data DP A = ProblemCtor' A 
diff --git a/html-test/src/Bug294.hs b/html-test/src/Bug294.hs new file mode 100644 index 00000000..4f874705 --- /dev/null +++ b/html-test/src/Bug294.hs @@ -0,0 +1,37 @@ +{-# LANGUAGE TypeFamilies, FlexibleInstances, GADTs #-} +-- This tests that we are able to extract record selectors for +-- associated types when the type itself is not exported. Making this +-- bug exhibit is very simple: simply mention a record field defined +-- inside of the associated type anywhere in the export list. +-- +-- Note: ProblemCtor only shows up when T or A are exported but PolyCtor +-- only shows up when the class is exported as well, since it's polymorphic. +module Bug294 ( A, problemField, problemField', gadtField + , TP(ProblemCtor), DP(ProblemCtor'), TO'(PolyCtor)) where + +data A + +class T t where + data TO t :: * + data TP t :: * + + t :: t + +instance T A where + data TO A = TA { problemField :: A } + data TP A = ProblemCtor A + +data family DO t :: * +data family DP t :: * + +data instance DO A = DA { problemField' :: A } +data instance DP A = ProblemCtor' A + +data GADT :: * -> * where + Ctor :: { gadtField :: A } -> GADT A + +class T' t where + data TO' t :: * + +instance T' a where + data TO' a = PolyCtor -- cgit v1.2.3