#1722: Code using type synonym families requires workarounds to compile
----------------------------------------+-----------------------------------
  Reporter:  [EMAIL PROTECTED]  |          Owner:         
      Type:  bug                        |         Status:  new    
  Priority:  normal                     |      Milestone:         
 Component:  Compiler (Type checker)    |        Version:  6.8    
  Severity:  normal                     |       Keywords:         
Difficulty:  Unknown                    |             Os:  Unknown
  Testcase:                             |   Architecture:  Unknown
----------------------------------------+-----------------------------------
I am trying to use type synonym families to create GADTs that can be used
 interchangably as both typed and untyped ASTs for a small programming
 language. Here are the (cut down & simplified) definitions:

 {{{
 data Typed
 data Untyped

 type family TU a b :: *
 type instance TU Typed b = b
 type instance TU Untyped b = ()

 -- A type witness type, use eg. for pattern-matching on types
 data Type a where
     TypeInt     :: Type Int
     TypeBool    :: Type Bool
     TypeString  :: Type String
     TypeList    :: Type t -> Type [t]

 data Expr :: * -> * -> * {- tu a -} where
     Const :: Type a -> a -> Expr tu (TU tu a)
     Var2  :: String -> TU tu (Type a) -> Expr tu (TU tu a)
 }}}

 It mostly works, which still amazes me, but there are some small glitches.
 For example in some cases I have to use '''(TU Typed Bool)''' instead of
 '''Bool''', even if they should be equal ('''type instance TU Typed b =
 b'''). In other cases I have to artificially restrict or generalize
 functions' type signatures. Or I have to put type signatures in patterns.
 The biggest problem is that it isn't obvious which workaround is needed in
 a given case. For some cases I don't have a satisfactory workaround yet.

 Perhaps these problems simply reflect immaturity of type synonym family
 support in GHC, but, on the other hand, it may be some simple bug which
 could be fixed for GHC 6.8.

 I've created a set of test files which I will attach to this ticket. Run
 check.sh to see how GHC handles the original (inteded) code and the
 workarounds. But first set the path to ghc in the script.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1722>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to