Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Nested data types and bisimilarity (Felipe Almeida Lessa)
   2.  Windows 7 time function (Sayth Renshaw)
   3. Re:  Monads (Brent Yorgey)
   4. Re:  Nested data types and bisimilarity (Brent Yorgey)
   5. Re:  Windows 7 time function (Daniel Huckstep)
   6. Re:  Windows 7 time function (Chadda? Fouch?)


----------------------------------------------------------------------

Message: 1
Date: Sat, 5 Mar 2011 02:51:46 +0000
From: Felipe Almeida Lessa <felipe.le...@gmail.com>
Subject: Re: [Haskell-beginners] Nested data types and bisimilarity
To: dan portin <danpor...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <AANLkTin=bwhNaT2CSroOccdea3jpFNbNg=kfefnia...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Sat, Mar 5, 2011 at 2:32 AM, dan portin <danpor...@gmail.com> wrote:
> Actually, let me rephrase the question. I know that a relation R over
> streams is a bisimulation if, for all lists l1 and l2, (a) their heads are
> equal and their tails are in the relation R, or (b) both l1 and l2 are
> empty. Similarly, I know that a relation R over in binary trees is a
> bisimulation if, for all trees t1 and t2, the values at the root node of t1
> and t2 are equal, and the left and right subtrees of t1 and t2 are in the
> relation R. From the definition of a bisimulation, the conditions for a
> relation R over types constructed from arrow, cross, and so on, is easy to
> derive.
>
> However, suppose I have a data type
>
> data N a = N a [N a]
>
> By analogy, I might suppose that a relation R over trees t1 and t2 of type N
> a is a bisimulation if (a) the values at their root node are equal, and (b)
> their forests are equal. However, proving equality using this definition can
> lead to a circular proof. For instance, it might be the case that the values
> at the roots of t1 and t2 are equal, but that the head of the forests of t1
> and t2 are, again, t1 and t2! (that is, assume T(t1,t2), and if their root
> values are equal, show that their forests are equal; if each is an infinite
> list, show that their heads are equal, but perhaps their heads are t1 and
> t2!). So I am slightly confused as to how equality of such types can be
> proved by the bisimulation method. In fact, I'm confused as to what the
> appropriate conditions are!

I don't really know much about bisimulations, so I may be missing the
point or going into the wrong direction.  So read this e-mail with a
grain of salt =).

Your N data type isn't the only one that may have some weird infinite
recursion.  Consider

  let xs = 1 : ys
      ys = 1 : xs

To prove that xs and ys are on a relation R, you have to proove that
ys and xs are on a relation R.  Oops!

As I said, I don't know much about bisimulations.  However, you don't
seem to think that there is a problem with xs/ys defined as above.  So
I am tempted to read your definition of a bisimulation on lists as
some form of induction.  Being explicit, let's define

  R_0 = { ([], []) }

as the relation with only the empty list and

  R_{n+1} = R_n ? { (x:s, x:t) | s, t ? R_n, x ? ? }

Now, (xs, ys) ? R_n for all n ? ?, as R_n contains lists of at most
length n, and xs/ys have infinite length.  However, (xs, ys) ? R_?,
where ? = |?| is the first ordinal.  In a real machine we only have
finite time, so we can't (in general) know for sure that (xs, ys) ? R.

Well, the same thing happens when you consider your N data type.  If you have

  let t1 = N 1 [t1, t2]
      t2 = N 1 [t2, t1]

then you can't know for sure in finite time in a machine in general
that (t1, t2) ? R, however you can given infinite countable time ?.

I hope that helps you to answer at least a little bit of your question =).

-- 
Felipe.



------------------------------

Message: 2
Date: Sat, 5 Mar 2011 14:17:45 +1100
From: Sayth Renshaw <flebber.c...@gmail.com>
Subject: [Haskell-beginners] Windows 7 time function
To: beginners@haskell.org
Message-ID:
        <AANLkTinY1o=YUJ=xcpmyfkndh-+rw4cyftmevfl9t...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I was completing the 5 step quickstart guide
http://www.haskell.org/haskellwiki/Haskell_in_5_steps

When running the program though haskell appears to be not able to access
time on windows 7. Would this be normal?

C:\Users\RenshawFamily\Documents\Scripts\Haskell>time ./A +RTS -N2
The system cannot accept the time entered.
Enter the new time:

C:\Users\RenshawFamily\Documents\Scripts\Haskell>time A.exe +RTS -N2
The system cannot accept the time entered.
Enter the new time: 14.13
A required privilege is not held by the client.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110305/e493c0a6/attachment-0001.htm>

------------------------------

Message: 3
Date: Fri, 4 Mar 2011 23:33:53 -0500
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] Monads
To: Patrick Lynch <kmandpjly...@verizon.net>
Cc: beginners@haskell.org
Message-ID: <20110305043353.ga23...@seas.upenn.edu>
Content-Type: text/plain; charset=us-ascii

On Fri, Mar 04, 2011 at 05:20:27PM -0500, Patrick Lynch wrote:
>
> I'd love to take a crack at Category Theory [my mathematics is good]
> but this looks like a formidable task...

It is not that formidable just to get started.  But it is so abstract
that it can be difficult to gain intuition for.  If you want to learn
some category theory I recommend Awodey's book.

> I'll proceed using the Monad classes and instances as is - and hope
> that at some point I'll be able to create my own Monads...

Creating one's own monads is overrated.  I almost never do it.
Usually I can just put something together using monad transformers
that fits my needs.

> 
> btw: can you create a class in Haskell -[I'm guessing the answer to
> this is no -- see below, it doesn't work]?
> 
>     class MyCalculator a where
>     myadd::( Num a) => a -> a -> a
>     myAdd x y = x + y

Sure, you can do that.  What do you mean when you say that it doesn't
work? 

-Brent

> 
> ----- Original Message ----- From: "Brent Yorgey"
> <byor...@seas.upenn.edu>
> To: <beginners@haskell.org>
> Cc: "Patrick Lynch" <kmandpjly...@verizon.net>
> Sent: Friday, March 04, 2011 3:07 PM
> Subject: Re: [Haskell-beginners] Monads
> 
> 
> >On Wed, Mar 02, 2011 at 04:38:07PM -0500, Patrick Lynch wrote:
> >>
> >>----- Original Message ----- From: "Brent Yorgey"
> >><byor...@seas.upenn.edu>
> >>To: <beginners@haskell.org>
> >>Sent: Wednesday, March 02, 2011 10:37 AM
> >>Subject: Re: [Haskell-beginners] Monads
> >>
> >>
> >>>On Wed, Mar 02, 2011 at 10:04:38AM -0500, Patrick Lynch wrote:
> >>>>Daniel,
> >>>>Thank you...I understand now...
> >>>>Good day
> >>>>
> >>>>    instance Functor Maybe where
> >>>>      fmap f (Just x) = Just (f x)
> >>>>      fmap f Nothing = Nothing
> >>>
> >>>So you are confused about this code?  Can you be more specific what
> >>>you are confused about?  Try thinking carefully about all the types
> >>>involved.  What is the type of f? (You already answered this: a -> b.)
> >>>What is the type of (Just x)? The type of x?  What type is required on
> >>>the right hand side of the = ?  And so on.
> >>
> >>
> >>-Hi Brent
> >>I know that Maybe type is: data Maybe a = Nothing | Just a
> >>...so, I assume that the type to the right of the '=' should be
> >>Maybe a..
> >
> >Not quite.  Let's look again at the type of fmap here:
> >
> > fmap :: (a -> b) -> Maybe a -> Maybe b
> >
> >So fmap will be taking *two* parameters, the first of type (a -> b),
> >the second of type Maybe a.  Then it needs to return something of type
> >Maybe b (so this is what will be on the right hand side of the =).
> >
> >>    instance Functor Maybe where
> >>      fmap Nothing = Nothing
> >>      fmap Just x = Just x
> >
> >You're missing the first argument to fmap (the one of type a -> b).
> >Let's call it f.  Since the second argument is of type (Maybe a)
> >you're right that we should handle all cases (Nothing and Just).
> >
> > fmap f Nothing = Nothing
> >
> >so here we need to return something of type 'Maybe b'.  Well, we don't
> >have any values of type b, so the only thing we can do is return
> >Nothing.
> >
> > fmap f (Just x) = ?
> >
> >The reason we need the parentheses around (Just x) is simply that
> >otherwise the compiler thinks we are writing a definition of fmap that
> >takes three arguments: f, Just, and x, but that doesn't make sense.
> >
> >Now, here f has type (a -> b), and (Just x) has type (Maybe a), hence
> >x has type a.  If we apply f to x we get something of type b, so we
> >can define
> >
> > fmap f (Just x) = Just (f x)
> >
> >Does that make sense?
> >
> >-Brent
> 



------------------------------

Message: 4
Date: Fri, 4 Mar 2011 23:40:44 -0500
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] Nested data types and bisimilarity
To: beginners@haskell.org
Message-ID: <20110305044044.gb23...@seas.upenn.edu>
Content-Type: text/plain; charset=us-ascii

On Sat, Mar 05, 2011 at 02:51:46AM +0000, Felipe Almeida Lessa wrote:
> 
> I don't really know much about bisimulations, so I may be missing the
> point or going into the wrong direction.  So read this e-mail with a
> grain of salt =).
> 
> Your N data type isn't the only one that may have some weird infinite
> recursion.  Consider
> 
>   let xs = 1 : ys
>       ys = 1 : xs
> 
> To prove that xs and ys are on a relation R, you have to proove that
> ys and xs are on a relation R.  Oops!

Actually, you are missing the point. ;)  The point of bisimulations is
that they are defined *coinductively*, so they let you work with
potentially infinite data structures.  In your example, proving that
xs and ys are in the relation R really is that simple -- 1 = 1, and
then to complete the proof we are allowed to use the coinduction
hypothesis that xs and ys are in the relation R, since they are
guarded by a constructor (:).  

Dan, does this help answer your original question?  If not I can try
to give a more detailed answer in the morning.

-Brent



------------------------------

Message: 5
Date: Fri, 4 Mar 2011 21:48:26 -0700
From: Daniel Huckstep <darkhel...@darkhelmetlive.com>
Subject: Re: [Haskell-beginners] Windows 7 time function
To: beginners@haskell.org
Message-ID: <iksfap$1jk$1...@dough.gmane.org>
Content-Type: text/plain; charset=iso-8859-1; format=flowed

The `time` program runs another programs and tells you how much time 
was spent running it (wall time, user, and system time).

This program doesn't exist on Windows, so you can ignore it.

- Daniel


On 2011-03-04 20:17:45 -0700, Sayth Renshaw said:

> I was completing the 5 step quickstart guide 
> http://www.haskell.org/haskellwiki/Haskell_in_5_steps
> 
> When running the program though haskell appears to be not able to 
> access time on windows 7. Would this be normal?
> 
> C:\Users\RenshawFamily\Documents\Scripts\Haskell>time ./A +RTS -N2
> The system cannot accept the time entered.
> Enter the new time:
> 
> C:\Users\RenshawFamily\Documents\Scripts\Haskell>time A.exe +RTS -N2
> The system cannot accept the time entered.
> Enter the new time: 14.13
> A required privilege is not held by the client.






------------------------------

Message: 6
Date: Sat, 5 Mar 2011 09:46:22 +0100
From: Chadda? Fouch? <chaddai.fou...@gmail.com>
Subject: Re: [Haskell-beginners] Windows 7 time function
To: Daniel Huckstep <darkhel...@darkhelmetlive.com>
Cc: beginners@haskell.org
Message-ID:
        <AANLkTimSPabHRy5Ud_vytLc6t=sv+tzpo0bbo4yk1...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Sat, Mar 5, 2011 at 5:48 AM, Daniel Huckstep
<darkhel...@darkhelmetlive.com> wrote:
> The `time` program runs another programs and tells you how much time was
> spent running it (wall time, user, and system time).
>
> This program doesn't exist on Windows, so you can ignore it.

Actually it does exist however it doesn't do the same thing as Unix
"time" : it just allows one to show or modify the system clock.
Of course this has absolutely nothing to do with Haskell and in fact
to measure performance of an Haskell program it is enough to use the
RTS to report those statistics :

C:\Users\RenshawFamily\Documents\Scripts\Haskell>A.exe +RTS -N2 -sstderr

should do the trick (note that you don't need time).

Or a library like criterion for more precise and interesting benchmark
(by the way if you use -N2 don't forget to compile your program with
the --threaded option to use the parallel RTS).

-- 
Jeda?



------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 33, Issue 6
****************************************

Reply via email to