FYI: Hoogle

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

FYI: Hoogle

Beitrag von sewe »

One thing that is nice about static typing in Haskell is that it has enabled the creation of function-search engines like Hoogle: http://www.haskell.org/hoogle/.

If you want to know whether Haskell has an equivalent of the zipOp procedure you used in the second assignment, just guess it's type and search for that: (a -> b -> c) -> [a] -> -> [c]. This turns up zipWith.

And yes, you don't have to guess the order of arguments correctly; it still works if you reorder them. Also, the above is as generic as it could be (three type variables: a, b, c). Using a less general query works too (although sometimes not quite as well): (a -> a -> a) -> [a] -> [a] -> [a] or even (Int -> Int -> Int) -> [Int] -> [Int] -> [Int].

So, have fun with Hoogle! Maybe its even useful to you on your next assignment. ;-)

DanielSchoepe
Mausschubser
Mausschubser
Beiträge: 49
Registriert: 28. Sep 2009 11:39

Re: FYI: Hoogle

Beitrag von DanielSchoepe »

Another useful (maybe not for the exercises, but in general) site for this purpose is Hayoo (Yes, names in the Haskell world are _that_ creative), which does a similar thing as hoogle, but also searches through the tons of packages available on Hackage. While this is probably not too useful for the exercises as we probably won't use any external libraries, it is very helpful for writing Haskell in other contexts. (Yes, people do use this language outside of university lectures! :))

Antworten

Zurück zu „Archiv“