Backpack creashes on default type families
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
If I create a class with an associated type family that has a default type, cabal crashes if I try to demand an instance of this class in a signature file. In particular it says:
```
: error:
The identifier R:BarStr does not exist in the local signature.
(Try adding it to the export list of the hsig file.)
```
where `Bar` is the type family associated with the type `Str`.
**To reproduce**, we'll start with https://github.com/ezyang/backpack-regex-example/tree/better-single-package
Then apply this diff:
```
diff --git a/regex-example.cabal b/regex-example.cabal
index 18cebd3..68ea75b 100644
--- a/regex-example.cabal
+++ b/regex-example.cabal
@@ -9,7 +9,7 @@ library str-impls
hs-source-dirs: str-impls
library regex-types
- build-depends: base
+ build-depends: base, bytestring
exposed-modules: Regex.Types
hs-source-dirs: regex-types
diff --git a/regex-indef/Str.hsig b/regex-indef/Str.hsig
index 23bfb8c..6e2aa0b 100644
--- a/regex-indef/Str.hsig
+++ b/regex-indef/Str.hsig
@@ -1,7 +1,9 @@
signature Str where
+import Regex.Types
data Str
instance Eq Str
+instance Foo Str
null :: Str -> Bool
singleton :: Char -> Str
diff --git a/regex-types/Regex/Types.hs b/regex-types/Regex/Types.hs
index 2900749..4fe4eb0 100644
--- a/regex-types/Regex/Types.hs
+++ b/regex-types/Regex/Types.hs
@@ -1,7 +1,16 @@
+{-# LANGUAGE FlexibleInstances, TypeFamilies #-}
module Regex.Types where
+import Data.ByteString
data Reg = Eps
| Sym Char
| Alt Reg Reg
| Seq Reg Reg
| Rep Reg
+
+class Foo x where
+ type Bar x :: *
+ type Bar x = ()
+
+instance Foo String
+instance Foo ByteString
```
and run `cabal v1-build` or `cabal v2-build` in the project directory.
I'm running GHC 8.6.5 and Cabal 2.4.1.0.
@ezyang ?
Contributor guide
Assessment
This issue has not been assessed yet.