[Haskell-beginners] Let the compiler do the work

David McBride toad3k at gmail.com
Mon Jan 19 14:41:07 UTC 2015


I believe the feature "typed holes" first came about around ghc 7.8.  I'm
not sure if there ever was a pragma for it because it got everyone so
excited it was just made to default on from its inception.

On Mon, Jan 19, 2015 at 9:29 AM, Elias Diem <lists at webconect.ch> wrote:

> Hi there
>
> I'm referring to a post from Stefan Höck and will quote from
> there:
>
> http://article.gmane.org/gmane.comp.lang.haskell.beginners/14198
>
> <quote>
> Now, load this into GHCi or compile with GHC. If it compiles, you're
> on the right track. Now, you want to implement it using a fold
> (try both, foldl and foldr):
>
>   last5 :: [a] -> Maybe a
>   last5 xs = foldr _ _ xs
>
> The underscores are 'type holes'. This tells the compiler to give you
> some information about what is supposed to be placed at the two
> positions. For the moment, we are only interested in the types of the
> things that go there. The compiler will tell you, that
> the hole at the first position is of type
>
>   a -> Maybe a -> Maybe a
> </quote>
>
> How does the compiler tell me this? I didn't find any flags
> for GHC to turn this on. What do I miss?
>
> --
> Greetings
> Elias
>
>
> _______________________________________________
> 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/20150119/ee5dc27b/attachment.html>


More information about the Beginners mailing list