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:  Design questions for a Pascal interpreter (Peter Verswyvelen)
   2. Re:  Re: data constructors (Sterling Clover)
   3.  Re: problem cabal install'ing hmatrix (Heinrich Apfelmus)
   4.  Re: data constructors (Heinrich Apfelmus)
   5.  WWAAA... I hate monads (Daniel Carrera)
   6. Re:  WWAAA... I hate monads (Colin Paul Adams)
   7. Re:  WWAAA... I hate monads (Daniel Carrera)
   8. Re:  WWAAA... I hate monads (Andrew Wagner)


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

Message: 1
Date: Tue, 21 Apr 2009 23:54:41 +0200
From: Peter Verswyvelen <[email protected]>
Subject: Re: [Haskell-beginners] Design questions for a Pascal
        interpreter
To: [email protected]
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Maybe you could get come inspiration from the BASIC interpreter written in
Haskell:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vintage-basic



On Tue, Apr 21, 2009 at 2:14 AM, <[email protected]> wrote:

> G'day all.
>
> Quoting Giuliano Vilela <[email protected]>:
>
>  - Keeping the whole AST in memory for the evalution phase seems
>> overkill. Is there a better way?
>>
>
> In this day and age, it's not considered overkill to keep an entire
> program in memory in a tree form.  Perl 5 does that, for example.
>
> However, Pascal is simple enough that it can be translated from
> within the parser.  Quite a few influential Pascal compilers,
> including the simplest ones such as Pascal-P and Pascal-S, and some
> not-so-simple ones such as Turbo Pascal, did not even generate an AST,
> but compiled straight to P-code or assembly code from within the parser.
>
>  - The evalution, I think, would be a set of nice pure mutually
>> recursive functions that do some pattern matching on the program AST.
>> I would pass the current stack and heap for those functions to use and
>> modify. Is the State monad a good fit for this task? Wouldn't the code
>> become "too imperative"?
>>
>
> Interpretation of an imperative language is imperative.  I wouldn't
> worry about it.
>
> You will probably end up using a few monad transformers, because you
> need to need at least I/O and a heap, and quite possibly a symbol
> table as well.
>
>  Obviously, to evaluate writeln I need to be in the IO monad. Here, my
>> whole scheme went down. Do I really have to mix my own state (stack,
>> heap) within the IO monad along my evaluation functions?
>>
>
> You really need to learn about monad transformers.  Try this for
> starters:
>
>    http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.17.268
>
> Good luck, and let us know how you go.
>
> Cheers,
> Andrew Bromage
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090421/4bb970c9/attachment-0001.htm

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

Message: 2
Date: Tue, 21 Apr 2009 22:18:49 -0400
From: Sterling Clover <[email protected]>
Subject: Re: [Haskell-beginners] Re: data constructors
To: Heinrich Apfelmus <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

Maybe just bikeshedding here (and on -beginners, no less), but this  
seems like a job for Data.Traversable.sequence?

sequence :: Monad m => t (m a) -> m (t a)

Cheers,
S.

On Apr 20, 2009, at 3:00 AM, Heinrich Apfelmus wrote:
>
> Functors sounds good to me.
>
>    data Named a = N Name a
>    data Timed a = T Time a
>
>    instance Functor Named where ...
>    instance Functor Timed where ...
>
>    convert :: Named [Timed Chord] -> Timed [Named Chord]
>
>
> Bu you can also use plain type synonyms
>
>    type Named a = (Name,a)
>    type Timed a = (Time,a)
>
> and write your own record selectors by hand
>
>    name :: Named a -> Name
>    name = fst
>
>    time :: Timed a -> Time
>    time = fst
>
>    value :: (b,a) -> a
>    value = snd
>
>
>
> Regards,
> apfelmus
>
> --
> http://apfelmus.nfshost.com
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners



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

Message: 3
Date: Wed, 22 Apr 2009 10:07:17 +0200
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: problem cabal install'ing hmatrix
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Erik Quaeghebeur wrote:
> $ cabal install hmatrix
> Resolving dependencies...
> Configuring hmatrix-0.5.1.1...
> Preprocessing library hmatrix-0.5.1.1...
> running dist/build/Numeric/GSL/Special/Internal_hsc_make failed
> command was: dist/build/Numeric/GSL/Special/Internal_hsc_make
>> dist/build/Numeric/GSL/Special/Internal.hs
> cabal: Error: some packages failed to install:
> hmatrix-0.5.1.1 failed during the building phase. The exception was:
> exit: ExitFailure 1
> 
> What should I do to diagnose/resolve this problem?
> I'm on Gentoo/amd64 and have also posted this question in the gentoo
> forums.

Try

   cabal install hmatrix --verbose

to get a more detailed failure report.

On Mac/PPC, the trickiest part for me was to meet the dependencies on C
libraries, and there was some x86 assembly instruction lurking around.

Otherwise, no idea. You might want to try the  [email protected]
 or  [email protected]  mailing lists.


Regards,
apfelmus

--
http://apfelmus.nfshost.com



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

Message: 4
Date: Wed, 22 Apr 2009 10:21:24 +0200
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: data constructors
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Sterling Clover wrote:
> Maybe just bikeshedding here (and on -beginners, no less), but this
> seems like a job for Data.Traversable.sequence?
> 
> sequence :: Monad m => t (m a) -> m (t a)
> 
> Cheers,
> S.
> 
> Heinrich Apfelmus wrote:
>>
>>    convert :: Named [Timed Chord] -> Timed [Named Chord]
>>

Great idea!

My type signature is wrong, it should actually read

   convert :: [Named [Timed Chord]] -> [Timed [Named Chord]]

I'm not sure whether  sequence  applies directly,

   type EventList a = [Timed a]

is not a monad. It's not quite an applicative functor either, because in

   (<*>) :: EventList (a -> b) -> EventList a -> EventList b

it's not clear what should happen to events from the left and right list
that are not simultaneous. This needs further thought.


Regards,
apfelmus

--
http://apfelmus.nfshost.com



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

Message: 5
Date: Wed, 22 Apr 2009 12:21:14 +0200
From: Daniel Carrera <[email protected]>
Subject: [Haskell-beginners] WWAAA... I hate monads
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I hate monads.

I love 90% of Haskell. The functional stuff is beautiful, easy to 
understand, crystal clear, elegant, etc. But I'm having a mighty hard 
time getting my head around monads. Consider the following explanation 
of a monad:

"A monad is represented as a type constructor (call it m), a function 
that builds values of that type (a -> m a), and a function that combines 
values of that type with computations that produce values of that type 
to produce a new computation for values of that type".

1) I know what a type is, but not a "type constructor". I don't normally 
think of an Int or even a complex type as being "constructed" except in 
the sense of OOP which I know is not what the author means.

2) Just *read* the paragraph... "a type constructor, a function that 
builds value of that type, and a function that combines values of that 
type with computations that produce values of that type to produce a 
computation of values of that type"   Ugh....


Can anyone recommend a simple and clear explanation of monads? You can 
assume that I know basic math and basic Haskell syntax. So, for example, 
"a -> b" is much more clear than "a function that takes input of one 
type and has an output of a different type".

Any help would be appreciated.

Daniel.


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

Message: 6
Date: Wed, 22 Apr 2009 11:26:06 +0100
From: Colin Paul Adams <[email protected]>
Subject: Re: [Haskell-beginners] WWAAA... I hate monads
To: Daniel Carrera <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

>>>>> "Daniel" == Daniel Carrera <[email protected]> writes:

    Daniel> Can anyone recommend a simple and clear explanation of
    Daniel> monads? You can assume that I know basic math and basic
    Daniel> Haskell syntax. So, for example, "a -> b" is much more
    Daniel> clear than "a function that takes input of one type and
    Daniel> has an output of a different type".

This is excellent:

http://ertes.de/articles/monads.html

-- 
Colin Adams
Preston Lancashire


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

Message: 7
Date: Wed, 22 Apr 2009 12:34:04 +0200
From: Daniel Carrera <[email protected]>
Subject: Re: [Haskell-beginners] WWAAA... I hate monads
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Colin Paul Adams wrote:
> This is excellent:
> 
> http://ertes.de/articles/monads.html

Thanks! I'll start reading that page immediately.

Cheers,
Daniel.


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

Message: 8
Date: Wed, 22 Apr 2009 06:55:49 -0400
From: Andrew Wagner <[email protected]>
Subject: Re: [Haskell-beginners] WWAAA... I hate monads
To: Daniel Carrera <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Here's a clearer description:class Monad m where
    return :: a -> m a
    (>>=) :: m a -> (a -> m b) -> m b

Instances of Monad must satisfy the following laws:
  return a >>= k == k a
  m >>= return == m
  m >>= (k >>= h) == (m >>= k) >>= h

Much more clear and concise, don't you think?

On Wed, Apr 22, 2009 at 6:21 AM, Daniel Carrera <
[email protected]> wrote:

> I hate monads.
>
> I love 90% of Haskell. The functional stuff is beautiful, easy to
> understand, crystal clear, elegant, etc. But I'm having a mighty hard time
> getting my head around monads. Consider the following explanation of a
> monad:
>
> "A monad is represented as a type constructor (call it m), a function that
> builds values of that type (a -> m a), and a function that combines values
> of that type with computations that produce values of that type to produce a
> new computation for values of that type".
>
> 1) I know what a type is, but not a "type constructor". I don't normally
> think of an Int or even a complex type as being "constructed" except in the
> sense of OOP which I know is not what the author means.
>
> 2) Just *read* the paragraph... "a type constructor, a function that builds
> value of that type, and a function that combines values of that type with
> computations that produce values of that type to produce a computation of
> values of that type"   Ugh....
>
>
> Can anyone recommend a simple and clear explanation of monads? You can
> assume that I know basic math and basic Haskell syntax. So, for example, "a
> -> b" is much more clear than "a function that takes input of one type and
> has an output of a different type".
>
> Any help would be appreciated.
>
> Daniel.
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090422/8185017c/attachment.htm

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

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


End of Beginners Digest, Vol 10, Issue 20
*****************************************

Reply via email to