[Haskell-beginners] How to understand the type "ShowS"?
Lyndon Maydwell
maydwell at gmail.com
Tue Sep 24 12:54:49 CEST 2013
Looks like it's a convenience for building up a compositions of "Show"s.
ShowS is indeed a synonym for a function. The type of shows alone isn't
enough to figure out how it behaves exactly, but testing it out in GHCi is
telling:
> [Prelude] λ :i ShowS
> type ShowS = String -> String -- Defined in `GHC.Show'
> [Prelude] λ :i shows
> shows :: Show a => a -> ShowS -- Defined in `GHC.Show'
> [Prelude] λ shows "asdf" "qwer"
> "\"asdf\"qwer"
On Tue, Sep 24, 2013 at 8:15 PM, yi lu <zhiwudazhanjiangshi at gmail.com>wrote:
> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130924/25df9a6f/attachment.htm>
More information about the Beginners
mailing list