Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. fixpoint operator for ULC with specific reduction property (ben)
2. Re: fixpoint operator for ULC with specific reduction
property (Heinrich Apfelmus)
3. Re: fixpoint operator for ULC with specific reduction
property (ben)
4. pred (succ n) (ben)
5. Eliminate repetitive monad/list code (John Smith)
6. Re: Eliminate repetitive monad/list code (Ozgur Akgun)
7. Re: Eliminate repetitive monad/list code (Tobias Brandt)
----------------------------------------------------------------------
Message: 1
Date: Thu, 04 Nov 2010 11:43:08 +0100
From: ben <[email protected]>
Subject: [Haskell-beginners] fixpoint operator for ULC with specific
reduction property
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hello,
I'm looking for a fixpoint operator Z for the untyped lambda calculus
that has the property
Z g --> g (Z g)
for any g.
The best-known fixpoint operator Y := \f. (\x. f (x x)) (\x. f (x x))
does not have this property, but only
Y g --> T <-- g (Y g)
for some T.
Does anybody know such a Z I'm looking for?
Greetings,
ben
ps. Please keep me in CC, since I'm not currently subscribed to the list.
------------------------------
Message: 2
Date: Thu, 04 Nov 2010 12:23:16 +0100
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: fixpoint operator for ULC with
specific reduction property
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
ben wrote:
> I'm looking for a fixpoint operator Z for the untyped lambda calculus
> that has the property
>
> Z g --> g (Z g)
>
> for any g.
>
> The best-known fixpoint operator Y := \f. (\x. f (x x)) (\x. f (x x))
> does not have this property, but only
>
> Y g --> T <-- g (Y g)
>
> for some T.
>
> Does anybody know such a Z I'm looking for?
I think the Turing fixed point combinator does exactly that. It's defined as
Theta = (λxf.f(xxf))(λxf.f(xxf))
Related:
http://www.mail-archive.com/[email protected]/msg43467.html
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
------------------------------
Message: 3
Date: Thu, 04 Nov 2010 16:07:12 +0100
From: ben <[email protected]>
Subject: [Haskell-beginners] Re: fixpoint operator for ULC with
specific reduction property
To: Heinrich Apfelmus <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Heinrich Apfelmus wrote:
> ben wrote:
>> I'm looking for a fixpoint operator Z for the untyped lambda calculus
>> that has the property
>>
>> Z g --> g (Z g)
>>
>> for any g.
>> [...]
> I think the Turing fixed point combinator does exactly that. It's
> defined as
>
> Theta = (λxf.f(xxf))(λxf.f(xxf))
> [...]
Theta precisely meets my needs.
Thanks a lot.
ben
------------------------------
Message: 4
Date: Thu, 04 Nov 2010 16:21:17 +0100
From: ben <[email protected]>
Subject: [Haskell-beginners] pred (succ n)
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hello,
this question is somewhat similar to the one I've asked some hours ago:
I would like to have a predecessor operator PRED for the untyped lambda
calculus that has the property that
PRED (SUCC n) --> n (I)
for a suitable successor function SUCC.
So far I've tried with
SUCC := S := \nfx.f (n f x)
and
PRED := P := \nfx.n (\gh.h (g f)) (\u.x) (\u.u)
for which I can prove beta equivalence
P (S n) == n
by induction on n, but not the property (I).
Could anybody give me a pointer?
Greetings,
ben
ps. Please keep me in CC, since I'm not currently subscribed to the list.
------------------------------
Message: 5
Date: Thu, 04 Nov 2010 18:19:50 +0200
From: John Smith <[email protected]>
Subject: [Haskell-beginners] Eliminate repetitive monad/list code
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
I have code which looks like this:
foo :: IO A
bar :: Bool -> A -> Int -> Bool -> IO ()
do
x <- foo
y <- foo
z <- foo
bar True x 1 False
bar True y 2 False
bar True z 3 False
What is the best way to factor it, including eliminating the temporary x,y,z
variables? I can get this down to
foo :: IO A
bar :: Bool -> A -> Int -> Bool -> IO ()
bar' a b = bar True a b False
do
x <- foo
y <- foo
z <- foo
bar x 1
bar y 2
bar z 3
but I don't know what to do next. Is there some form of list comprehension or
combination of map and lift which will
eliminate the repetition?
------------------------------
Message: 6
Date: Thu, 4 Nov 2010 16:33:14 +0000
From: Ozgur Akgun <[email protected]>
Subject: Re: [Haskell-beginners] Eliminate repetitive monad/list code
To: John Smith <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
Hi!
do
   x <- foo
   bar' x 1
is equivalent to:
foo >>= \ x -> bar' x 1
which is equivalent to
flip bar' 1 =<< foo
so, for the whole thing, you can say:
do
   flip bar' 1 =<< foo
   flip bar' 2 =<< foo
   flip bar' 3 =<< foo
and if you define bar'' as,
bar'' = flip bar'
then it boils down to,
do
   bar'' 1 =<< foo
   bar'' 2 =<< foo
   bar'' 3 =<< foo
To further get rid of the foo's, you might want to have a look at the
Reader monad. But that would be overkill, I think.
HTH,
On 4 November 2010 16:19, John Smith <[email protected]> wrote:
>
> I have code which looks like this:
>
> foo :: IO A
>
> bar :: Bool -> A -> Int -> Bool -> IO ()
>
> do
> Â x <- foo
> Â y <- foo
> Â z <- foo
>
> Â bar True x 1 False
> Â bar True y 2 False
> Â bar True z 3 False
>
> What is the best way to factor it, including eliminating the temporary x,y,z
> variables? I can get this down to
>
> foo :: IO A
>
> bar :: Bool -> A -> Int -> Bool -> IO ()
>
> bar' a b = bar True a b False
>
> do
> Â x <- foo
> Â y <- foo
> Â z <- foo
>
> Â bar x 1
> Â bar y 2
> Â bar z 3
>
> but I don't know what to do next. Is there some form of list comprehension or
> combination of map and lift which will eliminate the repetition?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
--
Ozgur Akgun
------------------------------
Message: 7
Date: Thu, 4 Nov 2010 17:33:33 +0100
From: Tobias Brandt <[email protected]>
Subject: Re: [Haskell-beginners] Eliminate repetitive monad/list code
To: John Smith <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 4 November 2010 17:19, John Smith <[email protected]> wrote:
> foo :: IO A
>
> bar :: Bool -> A -> Int -> Bool -> IO ()
>
> bar' a b = bar True a b False
>
> do
> x <- foo
> y <- foo
> z <- foo
>
> bar x 1
> bar y 2
> bar z 3
>
> but I don't know what to do next. Is there some form of list comprehension
> or combination of map and lift which will eliminate the repetition?
mapM_ (\x -> foo >>= flip bar x) [1,2,3]
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 29, Issue 5
****************************************