Commit 502ed454 authored by bbr's avatar bbr
Browse files

show instances now working

parent f84e194c
......@@ -815,9 +815,8 @@ showInstance opts t@(Type origName vis vars consdecls) =
showFunction showQ opts t@(Type origName vis vars consdecls)
| maybe False (elem Show) (lookup (snd $ typeName t) (extInsts opts))
= showsPrec [C.Rule [] (C.SimpleExpr (hasPresym "showsPrec")) []]
| otherwise = {-if isTuple (snd origName)
then showTuple
else-} showsPrec (map showsPrecRule consdecls++[showFreeVar])
| otherwise = showsPrec (map showsPrecRule consdecls
++[showFreeVar,showGenerator])
where
showParenArg (_,'(':_) = hasPresym "True"
showParenArg _ = if showQ then hasPresym "True" else lt (C.Var "d") app_prec
......@@ -881,6 +880,15 @@ showFunction showQ opts t@(Type origName vis vars consdecls)
(cons_ (char_ '_')
(app (hasPresym "show") (C.Var "i"))))) []
showGenerator = C.Rule [_x,
C.PComb (newModName,name++"Or") [C.PVar "r",_x]]
(C.SimpleExpr
(app (hasPresym "showString")
(cons_ (char_ '_')
(app (hasPresym "show")
(app (cusym "deref")
(C.Var "r")))))) []
readInstance :: Config.Options -> TypeDecl -> C.InstanceDecl
readInstance opts (Type origName@(modName,name) vis vars consdecls) =
C.Instance (map (\v -> C.TypeClass (has "Read") [toTVar v]) vars)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment