show returns GHC.Base.String
λ: :t putStr (show [1..10])
<interactive>:1:9: error:
- Couldn't match type [Char] with String
Expected type: String
Actual type: GHC.Base.String
- In the first argument of putStr, namely(show [1 .. 10])
In the expression: putStr (show [1 .. 10])
λ: :t show
show :: Show a => a -> GHC.Base.String
Intended?
Is there some easy workaround for now?
We definitely need a better story for this.
I think the typeclass Show would need to stay, as it is one of the hardcoded class in haskell (deriving Show works on any type), but we need to be smarter about hiding GHC.Base.String from the string. we have a LString (short for List String) to provide the compatibility bridge for example.
Now we need better story for the foundation String:
- show should be making foundation
Stringby default:
show :: GHC.Show a => a -> String
show a = fromList $ GHC.show a
- We need a default class to print our types natively without going through
[Char]. We might even need 2 of these, for example (name made up) to distinguish howShowis currently being used:
class UserShow a where
pretty :: a -> String
class DebugShow a where
debug :: a -> String
Perhaps DebugShow should be implemented generically for most data - you want the true underlying structure in most cases. Perhaps UserShow should be using pretty printing combinators. The existing Show is a weird point in the design space.