
ShowS is just a type alias for String -> String. Anywhere where you could put a function of type String -> String you could replace that with ShowS. Examples blah :: String -> String blah "abc" = "def" is no different than blah :: Shows blah "abc" = "def"
From the GHC.Show import
GHC.Show.showList__ :: (a -> ShowS) -> [a] -> ShowS
is equivalent to
GHC.Show.showList__ :: (a -> (String -> String)) -> [a] -> (String ->
String)
It can be a little confusing but a lot of times you use the same function
prototype and it is useful to just turn it into its own little type to
shorten the types in your code.
On Tue, Sep 24, 2013 at 6:15 AM, yi lu
Prelude> :i ShowS type ShowS = String -> String -- Defined in `GHC.Show'
It is a type of a function? I cannot understand this type, and don't know how to create functions of this type.
And this function "shows"
Prelude> :i shows shows :: Show a => a -> ShowS -- Defined in `GHC.Show'
I don't know how this function works.
Yi
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners