Code generated by pointfree does not compile

View: New views
2 Messages — Rating Filter:   Alert me  

Code generated by pointfree does not compile

by Boris Lykah :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all!

I was playing with pointfree tool from hackage and found that it produces wrong code for some functions which use list comprehension.

Here are several examples:

:main f x = concat [x:f x| x<-[0..x-1]]
f = fix ((join .) . flip flip [] . ((:) .) . ap (:) . (`ap` (enumFromTo 0 . subtract 1)) . ((<-) .) . ((|) =<<))
This does not compile because (<-) and (|) are used as functions whereas they are not.

:main map (+1) [x| x<-[0..x]]
[x | x <- [0..x] + 1]
This does not compile either because the result code tries to add one to list.

Why does this happen? This looks like a bug.

Thanks,
Boris Lykah

Re: Code generated by pointfree does not compile

by Luke Palmer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Nov 5, 2009 at 4:46 AM, Boris Lykah <lykahb@...> wrote:

>
> Hi all!
>
> I was playing with pointfree tool from hackage and found that it produces
> wrong code for some functions which use list comprehension.
>
> Here are several examples:
>
> :main f x = concat [x:f x| x<-[0..x-1]]
> f = fix ((join .) . flip flip [] . ((:) .) . ap (:) . (`ap` (enumFromTo 0 .
> subtract 1)) . ((<-) .) . ((|) =<<))
> This does not compile because (<-) and (|) are used as functions whereas
> they are not.

Looks like pointfree doesn't understand list comprehension syntax.
Convert to normal functional notation instead:

main f x = concat (map (\x -> x : f x) [0..x-1])

Luke
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe