[Haskell-cafe] Defining show for a function type.
Johan Grönqvist
johan.gronqvist at gmail.com
Mon Jul 10 11:44:15 EDT 2006
I am a haskell-beginner and I wish to write a Forth-like interpreter.
(Only for practice, no usefulness.)
I would like use a list (as stack) that can contain several kinds of values.
data Element = Int Int | Float Float | Func : Machine -> Machine | ...
Now I would like to have this type be an instance of the class Show, so
that I can see what the stack contains in ghci.
"deriving Show" is impossible as Func is not instance of Show. Can I
make it instance of Show? I just want to define something like
show (Func _) = "Function, cannot show"
and I am not interested in actually displaying any information about the
function, but I am interested in getting information about elements of
other kinds.
So far I have just guessed, but failed to produce anything that does not
give an error stating that my function is not of the form (T a b c)
where T is not an alias and a b c are simple type variables (or so).
Any help appreciated!
Johan
More information about the Haskell-Cafe
mailing list