[Haskell-cafe] why does Data.Text.Lazy.IO.readFile return the internal type Data.Text.Lazy.Internal.Text, when Data.Text.IO.readFile returns plain IO Data.Text.Text?

Daniel Fischer daniel.is.fischer at web.de
Fri Apr 30 17:09:05 EDT 2010

Am Freitag 30 April 2010 22:37:38 schrieb Thomas Hartman:
> *Main> :t Data.Text.IO.readFile
> Data.Text.IO.readFile :: FilePath -> IO T.Text
> but
> *Main> :t Data.Text.Lazy.IO.readFile
> Data.Text.Lazy.IO.readFile
>   :: FilePath -> IO text-


Prelude> :t Data.Text.Lazy.IO.readFile
  :: FilePath -> IO text-
Prelude> :t Data.Text.IO.readFile
  :: FilePath -> IO text-

> why does the lazy version use the internal type, whereas the strict
> version of Text IO just using plain Data.Text type?

Both are using the type from the corresponding .Internal, because that's 
where the type is defined (note that, as with ByteStrings, the strict and 
lazy types are different, lazy is basically a list of strict).
Now, the interesting question is, why is the one displayed as T.Text?
It must be what you import to your Main, but I don't know how to produce 
that effect.

> and how can I get from internal type to regular type when using
> Data.Text?

Use id :: a -> a 

> also the internal type doesn't appear to be reflected in the haddock:
> http://hackage.haskell.org/packages/archive/text/

Follow the 'Source' link at Data.Text.Lazy.Text, that sends you to

> ghc-pkg list | grep -i text
>     text-
> thanks for any help!

More information about the Haskell-Cafe mailing list