|
definition: |
showDictOf :: TypeExpr -> Maybe TAExpr
showDictOf te = case te of
TCons qtc tes -> do
sd <- typeCons2ShowDict qtc
sds <- mapM showDictOf tes
return $ AComb (showDictTypeOf te) (FuncPartCall 1)
(sd, foldr (~>) (showDictTypeOf te) (map showDictTypeOf tes))
sds
_ -> Nothing
where
typeCons2ShowDict (mn,tc)
| mn == "Prelude"
= maybe Nothing (Just . pre) (preludeType2ShowDict tc)
-- here we assume that a Show instance exists for the user-defined type
-- safer solution: check the program for the existence of this instance
| otherwise
= Just (mn, "_inst#Prelude.Show#" ++ mn ++ "." ++ tc ++ "#")
preludeType2ShowDict tc
| tc `elem` ["Int", "Float", "Char", "Bool", "Maybe", "Either",
"IOError", "Ordering"]
= Just $ "_inst#Prelude.Show#Prelude." ++ tc ++ "#"
| tc `elem` ["[]","()"] || "(," `isPrefixOf` tc
= Just $ "_inst#Prelude.Show#" ++ tc ++ "#"
| otherwise
= Nothing
|
|
demand: |
argument 1 |
|
deterministic: |
deterministic operation |
|
documentation: |
--------------------------------------------------------------------------- Generate Show dictionary argument for a given type, if possible (e.g., if the type is not polymorphic or functional). |
|
failfree: |
_ |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{({TCons}) |-> _ || ({TVar}) |-> _ || ({FuncType}) |-> _ || ({ForallType}) |-> _}
|
|
name: |
showDictOf |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
FlatCurry.Types.TypeExpr -> Prelude.Maybe (FlatCurry.Annotated.Types.AExpr FlatCurry.Types.TypeExpr) |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |