On Dec 4, 2007 1:28 AM, Don Stewart <[EMAIL PROTECTED]> wrote: > -- How to display results > instance Show Action where > show MoveOutOfBounds = "Sorry you can't move in that direction." > show (MoveBadTerrain a) = case a of > Wall -> "You walk into a wall." > Tree -> "There is a tree in the way." > otherwise -> "You can't move there." > show MoveOk = "Good move."
I always thought show was meant for returning a String that could be used to recreate the original data if you copy-pasted it in your code or if you used read (i.e. read . show == id). Reading the documentation more carefully, I see that [1] says that this property holds for *derived* instances, and says nothing about it in the general case. So, what's the deal here? May I use Show for anything without breaking conventions? And how about Read? Thanks! [1] http://haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#t%3AShow -- Felipe. _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
