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. Re:  FW: question (Brent Yorgey)
   2. Re:  FW: question (Magnus Therning)
   3.  How to correctly define data types? (Davi Santos)
   4. Re:  about parser question < Programming in haskell _ chapter
      8 > (Stephen Tetley)
   5. Re:  FW: question (Brent Yorgey)


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

Message: 1
Date: Mon, 18 Jul 2011 12:36:51 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] FW: question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Thu, Jul 14, 2011 at 10:40:17AM -0400, David Place wrote:
> On Jul 14, 2011, at 10:20 AM, Roelof Wobben wrote:
> 
> > The initial question was about the difference between what you call Latex 
> > and Haskell symbols.
> > 
> > I must say that this book explains things better then the other books I 
> > tried.
> 
> On the web page for that book, there are a number of code sample
> files to download.  Maybe you could look there for some good
> concrete examples of syntax.    Note that they are in Literary
> Programming Style.  

Usually that is called "literate" programming style.  However, I like
very much the idea of a literary programming style.  Good programs
should read like gripping novels. =)

-Brent



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

Message: 2
Date: Mon, 18 Jul 2011 18:42:57 +0200
From: Magnus Therning <[email protected]>
Subject: Re: [Haskell-beginners] FW: question
To: [email protected]
Message-ID: <20110718164257.GA2060@ohann>
Content-Type: text/plain; charset="us-ascii"

On Mon, Jul 18, 2011 at 12:36:51PM -0400, Brent Yorgey wrote:
> On Thu, Jul 14, 2011 at 10:40:17AM -0400, David Place wrote:
> > On Jul 14, 2011, at 10:20 AM, Roelof Wobben wrote:
> > 
> > > The initial question was about the difference between what you call Latex 
> > > and Haskell symbols.
> > > 
> > > I must say that this book explains things better then the other books I 
> > > tried.
> > 
> > On the web page for that book, there are a number of code sample
> > files to download.  Maybe you could look there for some good
> > concrete examples of syntax.    Note that they are in Literary
> > Programming Style.  
> 
> Usually that is called "literate" programming style.  However, I like
> very much the idea of a literary programming style.  Good programs
> should read like gripping novels. =)

Like mystery novels, with twists and unexpected turns?

That's often what programs do read like, but I would much prefer them
to be like books for small children; concise, to the point, and
exceedingly easy to read, even when one is tired.

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: [email protected]   jabber: [email protected]
twitter: magthe               http://therning.org/magnus

Most software today is very much like an Egyptian pyramid with
millions of bricks piled on top of each other, with no structural
integrity, but just done by brute force and thousands of slaves.
     -- Alan Kay
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110718/6ab867c5/attachment-0001.pgp>

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

Message: 3
Date: Mon, 18 Jul 2011 14:26:33 -0300
From: Davi Santos <[email protected]>
Subject: [Haskell-beginners] How to correctly define data types?
To: "[email protected]" <[email protected]>
Message-ID:
        <canwsst990vcaunab2nmufp_1+umwdbnyxwkupebbrqupqv5...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello (first post),
I have spent so many time learning typeclasses and thinking it was part of
Haskell essence... and suddenly I read the discussion "[Haskell-beginners]
Can fields in a record be optional?".
So typeclasses are not always recomended?

I'm implementing a Machine Learning framework and I am in a sort of related
dilemma.

I found three ways of implementing the same distance function between
"examples" (aka "attribute vectors" or simply "Float vectors" for mere
mortals :) ):

[obs: "Example" datatype will be added more fields later]

--------------first------------------------------------
module ML where

data Example =
     Example [Float] deriving (Show)

class ExampleClass a where
     (distance) :: a ?  a ?  Float

instance ExampleClass Example where
   (Example atts1) distance (Example atts2) =
        sqrt $ sum $ map (?(x, y) ?  (x-y)?2) $ zip atts1 atts2
=================================


--------------second------------------------------------
module ML where

data Example =
    Example {attributes :: [Float]} deriving (Show)

distance :: Example ?  Example ?  Float
distance ex1 ex2 =
        sqrt $ sum $ map (?(x, y) ?  (x-y)?2) $
                zip (attributes ex1) (attributes ex2)
=================================


--------------third------------------------------------
module ML where

data Example =
       Example [Float] deriving (Show)

distance :: Example ?  Example ?  Float
distance (Example att1) (Example att2) =
      sqrt $ sum $ map (?(x, y) ?  (x-y)?2) $
                zip (att1) (att2)
=================================


All three reserves the word "distance" for itself and the second reserves
also the word "attributes".
How could I implement the module ML and which would be the best way  to set
"attributes" outside the module?

Thanks


Davi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110718/7fa7f9fd/attachment-0001.htm>

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

Message: 4
Date: Mon, 18 Jul 2011 19:32:33 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] about parser question < Programming
        in haskell _ chapter 8 >
Cc: Beginners <[email protected]>
Message-ID:
        <cab2tprd1v2npjjlkhhwcqnn-nga4dhq9zwjz758ydua0egd...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Note that the presentation of functional parsers in the book
simplifies things a little, particularly the book avoids mentioning
newtypes explicitly though they are implicit in the section 8.9
Chapter Remarks.

The code on Graham Hutton's website uses newtypes and is is directly runnable:

http://www.cs.nott.ac.uk/~gmh/book.html#code

On 18 July 2011 12:17, Haisheng Wu <[email protected]> wrote:
> I think you can check full source code at its web site to see what you
> missed.
> My thought: did you make Parser as a instance of Monad?
> -Haisheng



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

Message: 5
Date: Mon, 18 Jul 2011 15:31:34 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] FW: question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Mon, Jul 18, 2011 at 06:42:57PM +0200, Magnus Therning wrote:
> On Mon, Jul 18, 2011 at 12:36:51PM -0400, Brent Yorgey wrote:
> > On Thu, Jul 14, 2011 at 10:40:17AM -0400, David Place wrote:
> > > On Jul 14, 2011, at 10:20 AM, Roelof Wobben wrote:
> > > 
> > > > The initial question was about the difference between what you call 
> > > > Latex and Haskell symbols.
> > > > 
> > > > I must say that this book explains things better then the other books I 
> > > > tried.
> > > 
> > > On the web page for that book, there are a number of code sample
> > > files to download.  Maybe you could look there for some good
> > > concrete examples of syntax.    Note that they are in Literary
> > > Programming Style.  
> > 
> > Usually that is called "literate" programming style.  However, I like
> > very much the idea of a literary programming style.  Good programs
> > should read like gripping novels. =)
> 
> Like mystery novels, with twists and unexpected turns?
> 
> That's often what programs do read like, but I would much prefer them
> to be like books for small children; concise, to the point, and
> exceedingly easy to read, even when one is tired.

It depends on the type of program.  If you have a complicated story to
tell, you have a complicated story to tell.  But good mystery novels
take a complicated story and tell it in a way that helps the reader
follow all the threads, appreciate the surprising twists, and come
away feeling satisfied.  Most programs do not read like that.

-Brent



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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 37, Issue 34
*****************************************

Reply via email to