Re: [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?
Am Samstag 01 Mai 2010 00:58:23 schrieb Felipe Lessa: > > It depends on what is on your scope: > > Prelude> :t Data.Text.Lazy.IO.readFile > Data.Text.Lazy.IO.readFile > > :: FilePath -> IO text-0.7.1.0:Data.Text.Lazy.Internal.Text > > Prelude> :m Data.Text.Lazy > Prelude Data.Text.Lazy> :t Data.Text.Lazy.IO.readFile > Data.Text.Lazy.IO.readFile :: FilePath -> IO Text > > HTH, Indirectly. From the original post: >> *Main> :t Data.Text.IO.readFile >> Data.Text.IO.readFile :: FilePath -> IO T.Text So the scope is the top level of the Main module. I didn't immediately figure out why it was displayed as T.Text. I couldn't reproduce that with a couple of different imports, but I only tried "import [qualified] Data.Text.IO as T". When I saw > Prelude> :m Data.Text.Lazy it became clear, he had "import qualified Data.Text as T" in Main, thanks :) > > -- > Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
On Fri, Apr 30, 2010 at 11:09:05PM +0200, Daniel Fischer wrote: > Hmm, > > Prelude> :t Data.Text.Lazy.IO.readFile > Data.Text.Lazy.IO.readFile > :: FilePath -> IO text-0.7.1.0:Data.Text.Lazy.Internal.Text > Prelude> :t Data.Text.IO.readFile > Data.Text.IO.readFile > :: FilePath -> IO text-0.7.1.0:Data.Text.Internal.Text It depends on what is on your scope: Prelude> :t Data.Text.Lazy.IO.readFile Data.Text.Lazy.IO.readFile :: FilePath -> IO text-0.7.1.0:Data.Text.Lazy.Internal.Text Prelude> :m Data.Text.Lazy Prelude Data.Text.Lazy> :t Data.Text.Lazy.IO.readFile Data.Text.Lazy.IO.readFile :: FilePath -> IO Text HTH, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
Am Samstag 01 Mai 2010 00:26:26 schrieb Bryan O'Sullivan: > On Fri, Apr 30, 2010 at 3:14 PM, Daniel Fischer wrote: > > Yes, I understood it so that he wanted to convert from > > Data.Text.Lazy.Internal.Text to Data.Text.Lazy.Text. > > It's the same type. That's why I suggested id. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
On Fri, Apr 30, 2010 at 3:14 PM, Daniel Fischer wrote: > > Yes, I understood it so that he wanted to convert from > Data.Text.Lazy.Internal.Text to Data.Text.Lazy.Text. > It's the same type. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
Am Freitag 30 April 2010 23:20:59 schrieb Edward Kmett: > On Fri, Apr 30, 2010 at 5:09 PM, Daniel Fischer wrote: > > and how can I get from internal type to regular type when using > > > > > Data.Text? > > > > Use id :: a -> a > > ;) > > > > Not quite, there is still a distinction between > > Data.Text(.Internal).Text > > and Data.Text.Lazy(.Internal).Text. Yes, I understood it so that he wanted to convert from Data.Text.Lazy.Internal.Text to Data.Text.Lazy.Text. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
On Fri, Apr 30, 2010 at 5:09 PM, Daniel Fischer wrote: > and how can I get from internal type to regular type when using > > > Data.Text? > > Use id :: a -> a > ;) > > Not quite, there is still a distinction between Data.Text(.Internal).Text and Data.Text.Lazy(.Internal).Text. but the machinery to work with the results he gets back are found in Data.Text.Lazy including the functions to turn it into a list of strict Text fragments. > > > > also the internal type doesn't appear to be reflected in the haddock: > > > > http://hackage.haskell.org/packages/archive/text/0.7.1.0/doc/html/Data-T > >ext-Lazy-IO.html > > Follow the 'Source' link at Data.Text.Lazy.Text, that sends you to > http://hackage.haskell.org/packages/archive/text/0.7.1.0/doc/html/src/Data- > Text-Lazy-Internal.html#Text > > > > > ghc-pkg list | grep -i text > > text-0.7.1.0 > > > > thanks for any help! > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
On Fri, Apr 30, 2010 at 1:37 PM, Thomas Hartman wrote: > > why does the lazy version use the internal type, whereas the strict > version of Text IO just using plain Data.Text type? > That's just ghci playing display games with you, based on the names under which you imported the modules. There are two Text types, strict and lazy, so the lazy IO module returns a lazy Text, while the strict ... well, you get it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
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-0.7.1.0:Data.Text.Lazy.Internal.Text > Hmm, Prelude> :t Data.Text.Lazy.IO.readFile Data.Text.Lazy.IO.readFile :: FilePath -> IO text-0.7.1.0:Data.Text.Lazy.Internal.Text Prelude> :t Data.Text.IO.readFile Data.Text.IO.readFile :: FilePath -> IO text-0.7.1.0:Data.Text.Internal.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/0.7.1.0/doc/html/Data-T >ext-Lazy-IO.html Follow the 'Source' link at Data.Text.Lazy.Text, that sends you to http://hackage.haskell.org/packages/archive/text/0.7.1.0/doc/html/src/Data- Text-Lazy-Internal.html#Text > > ghc-pkg list | grep -i text > text-0.7.1.0 > > thanks for any help! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [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?
Data.Text.Lazy.Internal.Text = Data.Text.Lazy.Text Data.Text.Internal.Text = Data.Text.Text You can use fromChunks/toChunks from Data.Text.Lazy to break it up into strict Text fragments. The lazy version returns a Lazy Text value, which is isomorphic to [Data.Text.Text]. The strict version just returns a single strict Text value. On Fri, Apr 30, 2010 at 4:37 PM, Thomas Hartman wrote: > *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-0.7.1.0:Data.Text.Lazy.Internal.Text > > why does the lazy version use the internal type, whereas the strict > version of Text IO just using plain Data.Text type? > and how can I get from internal type to regular type when using Data.Text? > > also the internal type doesn't appear to be reflected in the haddock: > > http://hackage.haskell.org/packages/archive/text/0.7.1.0/doc/html/Data-Text-Lazy-IO.html > > ghc-pkg list | grep -i text >text-0.7.1.0 > > thanks for any help! > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[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?
*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-0.7.1.0:Data.Text.Lazy.Internal.Text why does the lazy version use the internal type, whereas the strict version of Text IO just using plain Data.Text type? and how can I get from internal type to regular type when using Data.Text? also the internal type doesn't appear to be reflected in the haddock: http://hackage.haskell.org/packages/archive/text/0.7.1.0/doc/html/Data-Text-Lazy-IO.html ghc-pkg list | grep -i text text-0.7.1.0 thanks for any help! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe