[Haskell-beginners] fnc explanation
vale.cofershabica at gmail.com
Mon Jan 2 21:21:31 UTC 2017
It might also help to look at the type of foldr:
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
The function go has type:
go :: Ord a => a -> (Maybe a, Bool) -> (Maybe a, Bool)
The tuple, initially (Nothing, True), will be passed to go as its *2nd*
argument; the first argument will be an element of the list. The
underscore, which means match anything and throw it away, is there because
we don't care about any of the other elements once we know the list is not
Hope that helps,
On Mon, Jan 2, 2017 at 12:20 PM, Daniel Trstenjak <
daniel.trstenjak at gmail.com> wrote:
> Hi Sasa,
> > -- this confuses me, what is the _ here ? go is anonymous function, _
> should stand for tuple ? and status xs from the top definition ?
> > go _ status@(_, False) = status
> The first argument of 'go' is '_', which means it's ignored.
> The second argument is 'status@(_, False)'.
> It's giving the tuple the name 'status' and pattern matching the tuple at
> If the pattern match succeeds, then the tuple named 'status' is returned
> by 'go'
> Beginners mailing list
> Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners