Sterling Clover | 22 Apr 04:18 2009
Picon

Re: Re: data constructors

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
(Continue reading)

Heinrich Apfelmus | 22 Apr 10:07 2009
Picon

Re: problem cabal install'ing hmatrix

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  haskell-cafe <at> haskell.org
 or  libraries <at> haskell.org  mailing lists.

Regards,
apfelmus
(Continue reading)

Heinrich Apfelmus | 22 Apr 10:21 2009
Picon

Re: data constructors

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.
(Continue reading)

Daniel Carrera | 22 Apr 12:21 2009

WWAAA... I hate monads

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.
(Continue reading)

Colin Paul Adams | 22 Apr 12:26 2009
Picon
Picon

Re: WWAAA... I hate monads

>>>>> "Daniel" == Daniel Carrera <daniel.carrera <at> theingots.org> 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
Daniel Carrera | 22 Apr 12:34 2009

Re: WWAAA... I hate monads

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

Thanks! I'll start reading that page immediately.

Cheers,
Daniel.
Andrew Wagner | 22 Apr 12:55 2009
Picon

Re: WWAAA... I hate monads

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 <daniel.carrera <at> theingots.org> 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
Beginners <at> haskell.org
http://www.haskell.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
Beginners <at> haskell.org
http://www.haskell.org/mailman/listinfo/beginners
Daniel Carrera | 22 Apr 13:01 2009

Re: WWAAA... I hate monads

Daniel Carrera wrote:
> Colin Paul Adams wrote:
>> This is excellent:
>>
>> http://ertes.de/articles/monads.html
> 
> Thanks! I'll start reading that page immediately.

I noticed that this tutorial points to the following blog:

http://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/

Wow! The author of this blog has nailed it. Trust me, I know, I was a 
math teacher for years (a *good* teacher, based on student reviews). The 
author of this blog is exactly right about why most tutorials about 
abstract concepts are no help (and why so many math teachers are bad).

Now I'll go on to read the tutorial, encouraged that the author probably 
knows how to teach.

Cheers,
Daniel.
Jason Dusek | 22 Apr 13:26 2009
Picon

Re: WWAAA... I hate monads

2009/04/22 Daniel Carrera <daniel.carrera <at> theingots.org>:
> I hate monads.

  Yikes! How do you feel about functors?

> 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.

  Well, an object constructor takes values and makes a value. A
  type constructor takes types and makes a type. You've probably
  seen a few type constructors in your life, for example,
  `std::vector`, which makes vectors of type `std::vector<t>`.
  Likewise, `std::map` is a two argument type constructor.

> 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....

  I don't think you should take your first impression too
  seriously here. The notion of combining computations is really
  crucial to working with monads; you'll find it's pretty hard
  to get used to at first, no matter how it's presented.

--
Jason Dusek
Thomas Davie | 22 Apr 13:42 2009
Picon

Re: WWAAA... I hate monads


On 22 Apr 2009, at 12:26, Colin Paul Adams wrote:

>>>>>> "Daniel" == Daniel Carrera <daniel.carrera <at> theingots.org> 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

Hopefully this will help too - monads are made rather too much of,  
just build up slowly to them rather than diving into them first –  
they're not the be all and end all of classes.

http://noordering.wordpress.com/2009/03/31/how-you-shouldnt-use-monad/

Bob

Gmane