[Haskell-cafe] showing a user defined type
nowgate at yahoo.com
Mon May 18 21:19:21 EDT 2009
I've been playing around with "The Little MLer" (pg. 95, 96) to try to improve my understanding of types.
I can ask ML:
val it = Link (1,fn) : chain
*Main> :t ints 0
ints 0 :: Chain
*Main> ints 0
No instance for (Show Chain)
arising from a use of `print' at <interactive>:1:0-5
Possible fix: add an instance declaration for (Show Chain)
In a stmt of a 'do' expression: print it
I think I need to write a show function for type Chain but not
sure how to proceed.
datatype chain =
Link of (int * (int -> chain))
= Link(n + 1, ints)
data Chain = Link Int (Int -> Chain)
ints :: Int -> Chain
ints n = Link (n+1) ints
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe