[generate a data type to represent jhc types when compiling via ghc
John Meacham <john@repetae.net>**20061111041614] hunk ./E/ToHs.hs 66
-transDataTable dataTable ns = vcat (map g $ Set.toList (mconcatMap f (Set.toList ns))) where
+transDataTable dataTable ns = vcat (theType:map g (lefts wtd)) where
+    wtd =  Set.toList (mconcatMap f (Set.toList ns))
hunk ./E/ToHs.hs 71
-    f w@(n,_,tl) = case (nameType n,tl) of
+    f w@(n,nn,tl) = case (nameType n,tl) of
hunk ./E/ToHs.hs 74
-            return (conInhabits c)
-        (TypeConstructor,True) -> Set.singleton n
-        (_RawType,_) -> Set.empty
+            return (Left $ conInhabits c)
+        (TypeConstructor,True) -> Set.singleton (Left n)
+        (TypeConstructor,False) -> Set.singleton (Right (n,nn))
+        (RawType,_) -> Set.empty
hunk ./E/ToHs.hs 79
+    theType = text "data Type = Char | Int" <+> case rights wtd of
+        [] -> empty
+        as -> text "|" <+> hcat (punctuate (text " | ") (map tt as))
+    tt (n,nn) = hsep (showTCName nn n:replicate nn (text "Type"))
+
hunk ./E/ToHs.hs 85
-        ans = text "data" <+> hsep (showCName n:[ text ('x':show i) | _ <- conSlots con | i <- [2::Int,4 ..] ]) <+> dchildren
+        ans = text "data" <+> hsep (showTCName (length $ conSlots con) n:[ text ('x':show i) | _ <- conSlots con | i <- [2::Int,4 ..] ]) <+> dchildren
hunk ./E/ToHs.hs 135
-showCon c [] = showCName c
-showCon c ts = parens $ hsep (showCName c:ts)
+showCon c [] = showTCName 0 c
+showCon c ts = parens $ hsep (showTCName (length ts) c:ts)
+
+showTCName n c | nameType c == TypeConstructor = showCName c <> text "_" <> tshow n
+showTCName _ c = showCName c
+
hunk ./E/ToHs.hs 160
+transType (ESort EStar) = return $ text "Type"
hunk ./E/ToHs.hs 273
+transAlt dobind b (Alt (LitInt num t) e) | t == tCharzh || t == rawType "wchar_t" = do
+    e <- noParens $ transE e
+    return ( (if dobind then b <> char '@' else empty) <> text (show $ chr $ fromIntegral num) <> text "#" <+> text "->" <+> e)