ekmett / lens

Lenses, Folds, and Traversals - Join us on web.libera.chat #haskell-lens
http://lens.github.io/
Other
2.03k stars 272 forks source link

Where is the `Iso' Text String`? #1062

Open kindaro opened 6 months ago

kindaro commented 6 months ago

Take a look at this definition:

string ∷ Iso' Text String
string = iso Text.unpack Text.pack

I thought I shall find it in lens. I do not see why it should not be there:

Yet I could not find anything like this.

ocharles commented 6 months ago

It's unpacked: https://hackage.haskell.org/package/lens-5.2.3/docs/Data-Text-Lens.html

kindaro commented 6 months ago

Makes sense. I did not think this stuff would be in a module of its own.

However, Hoogle cannot find these functions by type. I go by the link https://hoogle.haskell.org/?hoogle=Iso%27%20String%20text and there is nothing. Hoogle can find them by name though: the link https://hoogle.haskell.org/?hoogle=packed gives all the right hits from lens. What am I doing wrong?

ocharles commented 6 months ago

I don't think Stackage knows about type aliases

RyanGlScott commented 6 months ago

Hoogle is a bit quirky. If you search for :: Iso' String text (note the double colons), then packed does appear in the search results, albeit not as the first result. If you refine the search further to :: Iso' String Text, then it's the first result.

phadej commented 6 months ago

... it's indeed quirky, as the expansion :: Iso String String Text Text doesn't result in packed. I.e. you need to know what to search for find anything. Hoogle treats types as opaque, and in type-alias heavy library it's not great (even with optics where full expansion still "makes sense", Hoogle doesn't find anything).