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.  [m [a]] -> m [a] (Guy)
   2. Re:  [m [a]] -> m [a] (Daniel Fischer)
   3. Re:  [m [a]] -> m [a] (Guy)
   4. Re:  [m [a]] -> m [a] (Daniel Fischer)
   5. Re:  Question: Data Type for user selection (Brent Yorgey)
   6. Re:  [m [a]] -> m [a] (Brent Yorgey)
   7. Re:  How to find a "best alternative" (Henk-Jan van Tuyl)
   8. Re:  [m [a]] -> m [a] (Tony Morris)


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

Message: 1
Date: Wed, 17 Aug 2011 14:20:55 +0300
From: Guy <[email protected]>
Subject: [Haskell-beginners] [m [a]] -> m [a]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Is there a function which can do this, where m is not mplus?

I would like all the lists to be joined inside the monad with ++.




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

Message: 2
Date: Wed, 17 Aug 2011 13:32:00 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] [m [a]] -> m [a]
To: [email protected]
Cc: Guy <[email protected]>
Message-ID: <[email protected]>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Wednesday 17 August 2011, 13:20:55, Guy wrote:
> Is there a function which can do this, where m is not mplus?
> 
> I would like all the lists to be joined inside the monad with ++.

sequence gives you m [[a]], then an fmap concat (or liftM concat, since 
fmap requires an additional Functor constraint) flattens the resulting list 
to m [a].



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

Message: 3
Date: Wed, 17 Aug 2011 15:05:43 +0300
From: Guy <[email protected]>
Subject: Re: [Haskell-beginners] [m [a]] -> m [a]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 17/08/2011 14:32, Daniel Fischer wrote:
> On Wednesday 17 August 2011, 13:20:55, Guy wrote:
>> Is there a function which can do this, where m is not mplus?
>>
>> I would like all the lists to be joined inside the monad with ++.
>
> sequence gives you m [[a]], then an fmap concat (or liftM concat, since
> fmap requires an additional Functor constraint) flattens the resulting list
> to m [a].

Thanks. I was hoping that there would be some kind of fold that could do this; 
I take it there isn't one?




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

Message: 4
Date: Wed, 17 Aug 2011 14:33:20 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] [m [a]] -> m [a]
To: [email protected]
Cc: Guy <[email protected]>
Message-ID: <[email protected]>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Wednesday 17 August 2011, 14:05:43, Guy wrote:
> On 17/08/2011 14:32, Daniel Fischer wrote:
> > On Wednesday 17 August 2011, 13:20:55, Guy wrote:
> >> Is there a function which can do this, where m is not mplus?
> >> 
> >> I would like all the lists to be joined inside the monad with ++.
> > 
> > sequence gives you m [[a]], then an fmap concat (or liftM concat,
> > since fmap requires an additional Functor constraint) flattens the
> > resulting list to m [a].
> 
> Thanks. I was hoping that there would be some kind of fold that could do
> this; I take it there isn't one?
> 

Well, sequence is a fold, and concat is a fold. You can fuse them

foldr (\x xs -> x >>= \ys -> xs >>= \zs -> return (ys ++ zs)) (return [])

but is that really more readable?



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

Message: 5
Date: Wed, 17 Aug 2011 09:42:37 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Question: Data Type for user
        selection
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Tue, Aug 16, 2011 at 04:44:15PM +0200, Ertugrul Soeylemez wrote:
> Brent Yorgey <[email protected]> wrote:
> 
> > > That's a bit of a contradiction, because you are using existentials
> > > yourself in your GADT.
> >
> > No, he isn't.
> >
> >    data BasicSelect a where
> >      SelectionNum :: Num a => a -> BasicSelect a
> >      SelectionStr :: Show a => a -> BasicSelect a
> >
> > 'a' shows up in the result type of both constructors, so there is no
> > existential quantification going on here.
> 
> Oh, right.  How would one express this as an ADT?  Seems impossible to
> me.

You cannot, with just Haskell 2010.  Strangely, if you try this:

  data BasicSelect a = Num a  => SelectionNum a 
                     | Show a => SelectionStr a

you get this error (ghc 7.0.3):

  Data constructor `SelectionNum' has existential type variables, or a
  context
    (Use -XExistentialQuantification or -XGADTs to allow this)
  In the definition of data constructor `SelectionNum'
  In the data type declaration for `BasicSelect'

And enabling ExistentialQuantification makes the error go away!  So
apparently the ExistentialQuantification flag also enables type class
constraints on data constructors, even when no existential
quantification is involved.  Odd.

-Brent



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

Message: 6
Date: Wed, 17 Aug 2011 09:47:04 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] [m [a]] -> m [a]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Wed, Aug 17, 2011 at 01:32:00PM +0200, Daniel Fischer wrote:
> On Wednesday 17 August 2011, 13:20:55, Guy wrote:
> > Is there a function which can do this, where m is not mplus?
> > 
> > I would like all the lists to be joined inside the monad with ++.
> 
> sequence gives you m [[a]], then an fmap concat (or liftM concat, since 

http://spl.smugmug.com/Humor/Lambdacats/lift-concat/960794992_KUg77-M-1.jpg






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

Message: 7
Date: Wed, 17 Aug 2011 16:13:59 +0200
From: "Henk-Jan van Tuyl" <[email protected]>
Subject: Re: [Haskell-beginners] How to find a "best alternative"
To: [email protected], "Martin Drautzburg"
        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

On Sun, 14 Aug 2011 21:11:21 +0200, Martin Drautzburg  
<[email protected]> wrote:

> Hello all,
>
> I want to write transformations on musical motives and I came upon the
> following algorithmic question:
>

I think you have a better chance of an answer on the Haskell-cafe mailing  
list, as there more people reading that list. There are several Haskellers  
with music expertise.

Regards,
Henk-Jan van Tuyl


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--



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

Message: 8
Date: Thu, 18 Aug 2011 09:50:25 +1000
From: Tony Morris <[email protected]>
Subject: Re: [Haskell-beginners] [m [a]] -> m [a]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

mapM join

On 08/17/2011 09:20 PM, Guy wrote:
> Is there a function which can do this, where m is not mplus?
>
> I would like all the lists to be joined inside the monad with ++.
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners


-- 
Tony Morris
http://tmorris.net/





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

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


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

Reply via email to