Re: curried fun

From: Sebastian Hanowski <sebastian.hanowski_at_web.de>
Date: Thu, 20 Mar 2008 18:46:26 +0100

* Am 19.03.08 schrieb Sergio Antoy:
> Sebastian,
>
> Interesting snippets! Nothing specific to parallelism, right?

No, you're right even if had sent the program that I intended to:

        pmap :: (a -> b) -> [a] -> [b]
        pmap _ [] = []
        pmap f (x:xs) | y =:<= f x & ys =:<= pmap f xs = y : ys
                        where
                        y,ys free

        fix :: ((a -> b) -> (a -> b)) -> (a -> b)
        fix f a = foldr1 (?) [k a | k <- chain]
                where
                chain = failed : pmap f chain


I need more time to consider your programs and it's specifications
respectively. Until now I only have these two following remarks.

Best regards,
Sebastian

First, I'd argue that your function /f/

        data Token = Stop | Loop | Fail

        -- f :: Token -> Token
        -- f Stop = Stop
        -- f Loop = f Loop

 does the same as this one

        f :: Token -> Maybe ()
        f Stop = Just ()
        f Loop = Just bot where bot = bot
        f Fail = Nothing

because /pattern match failure/ is a finite failure and hence
observable.

And secondly I'd like to note that your function /g/

        -- g :: (Token,Token) -> (Token,Token)
        -- g (a,b) = (f a, f b)

 could be factored with the help of a function /pair/ which does for
tuples what /map/ does for lists.

        g :: (Token,Token) -> (Maybe (),Maybe ())
        g = pair f f

 And which could be implemented following the idea for the parallel
/map/.

        pair :: (a -> c) -> (b -> d) -> (a,b) -> (c,d)
        pair h k (a,b) | a' =:<= (h a) & b' =:<= (k b) = (a',b')
                        where a',b' free

But this still does not suffice to meet your specifications.
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on So Mär 23 2008 - 19:01:28 CET

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:09 CEST