Tom Hawkins | 14 Mar 2008 15:28
Picon

single element tuple

Hi,

Printing the core one of my programs I see:

  data Prelude;1() a =
    Preluse;1() a

What is this?  A single element tuple?  I didn't think Haskell had
these.  My program has a monad similar to IO.  It appears these
Prelude;1() things are created in the lambda lifted version of f1.
Perhaps is it the parenthesis around (System m)?

data Return a = Return a World
data System a = System (World -> Return a)
data World = World
instance Monad System where
  (System m) >>= k = System f1
    where
    f1 w = f2 w'
      where
      Return r w' = m w
      System f2 = k r

  return a = System (\ w -> Return a w)

It's a bit difficult to correlate arguments of lifted lambdas to the
original source.  Is there a convention YHC uses for adding the extra
arguments to lifted lambdas?

Thanks!
(Continue reading)

Tom Hawkins | 14 Mar 2008 16:06
Picon

Re: single element tuple

On 3/14/08, Tom Hawkins <tomahawkins <at> gmail.com> wrote:

> It appears these Prelude;1() things are created in the lambda lifted version of f1.

Actually that's not true.  They're only cased in f1.  But I don't see
them constructed anywhere.

-Tom
Neil Mitchell | 14 Mar 2008 16:58
Picon
Gravatar

Re: Re: single element tuple

Hi

>  > It appears these Prelude;1() things are created in the lambda lifted version of f1.
>
>  Actually that's not true.  They're only cased in f1.  But I don't see
>  them constructed anywhere.

Have you done --linkcore to see all the library Core files as well?
They should be created somewhere.

Thanks

Neil
Tom Shackell | 14 Mar 2008 16:04
Picon

Re: single element tuple

 > Hi,
 >
 > Printing the core one of my programs I see:
 >
 >   data Prelude;1() a =
 >     Preluse;1() a
 >
 > What is this?  A single element tuple?  I didn't think Haskell had
 > these.  My program has a monad similar to IO.  It appears these
 > Prelude;1() things are created in the lambda lifted version of f1.
 > Perhaps is it the parenthesis around (System m)?

Indeed Yhc has the 1 tuple. You can't write it in any programs but the 
compiler does generate things that use it. The reason is that classes 
are implemented as tuples of functions. For example

instance Eq MyData where
     x == y = False
     x /= y = True

f :: [MyData] -> MyData -> Bool
f ds d = elem d ds

elem :: Eq a => a -> [a] -> Bool
elem x [] = False
elem x (y:ys) | x == y = True
               | otherwise = elem x ys

this is compiled into something along the lines of

(Continue reading)


Gmane