[Haskell-beginners] List comprehension question
Daniel Fischer
daniel.is.fischer at googlemail.com
Wed Nov 23 01:22:55 CET 2011
On Wednesday 23 November 2011, 01:08:26, Lee Short wrote:
> So hlint suggests that I convert the line
>
> checked = if ival==input then [("checked","checked")] else []
>
> to
>
> checked = [("checked","checked") | ival==input]
>
> I'm not really sure why this works. Is there some implicit list being
> filtered by ival==input? What's going on?
A list comprehension
[expression | condition]
desugars to
if condition then [expression] else []
IMO, that's one of the places where hlint doesn't suggest an improvement.
More information about the Beginners
mailing list