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.  Good way of combining functions of type IO       (Maybe a)
      (Nathan H?sken)
   2. Re:  Good way of combining functions of type IO (Maybe a)
      (David McBride)
   3.  list problem (Roelof Wobben)
   4.   list problem (Benjamin Edwards)
   5. Re:  Good way of combining functions of type IO (Maybe a)
      (Chris Schneider)
   6. Re:  list problem (Roelof Wobben)


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

Message: 1
Date: Mon, 03 Mar 2014 16:10:05 +0100
From: Nathan H?sken <[email protected]>
To: Haskell Beginners Mailinglist <[email protected]>
Subject: [Haskell-beginners] Good way of combining functions of type
        IO      (Maybe a)
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Hey,

I want to write a function, which is basically a concatenation of
functions of type "IO (Maybe a)".
When they all where of type "Maybe a", no Problem I would simple use the
Maybe monad.

|func :: Maybe c
func = do
  a <- f1
  b <- d2 a
  ...
|

but now they are of type "IO (Maybe a)". Is there some way of combing
these in a similar smart way?

Thanks!
Nathan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140303/44ca1bfa/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140303/44ca1bfa/attachment-0001.sig>

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

Message: 2
Date: Mon, 3 Mar 2014 10:21:03 -0500
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Good way of combining functions of
        type IO (Maybe a)
Message-ID:
        <CAN+Tr404r+XWZkmJjfBmwQSOnbdi8sMgwytL7w=fubbkcd0...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

cabal install maybet

import Control.Monad.Maybe

f1 :: IO (Maybe Int)
f1 = return . Just $ 1

d2 :: Int -> IO (Maybe String)
d2 = return . Just . show

blah :: IO (Maybe (Int, String))
blah = do
  runMaybeT $ do
  a <- MaybeT f1
  b <- MaybeT $ d2 a
  return (a,b)

Or slightly rewritten:

f1 :: MaybeT IO Int
f1 = return 1
-- f1 = fail "why oh why?!?"

d2 :: Int -> MaybeT IO String
d2 = return . show

blah = do
  runMaybeT $ do
  a <- f1
  b <- d2 a
  return (a,b)



On Mon, Mar 3, 2014 at 10:10 AM, Nathan H?sken <[email protected]>wrote:

>  Hey,
>
> I want to write a function, which is basically a concatenation of
> functions of type "IO (Maybe a)".
> When they all where of type "Maybe a", no Problem I would simple use the
> Maybe monad.
>
> func :: Maybe cfunc = do
>   a <- f1
>   b <- d2 a
>   ...
>
> but now they are of type "IO (Maybe a)". Is there some way of combing
> these in a similar smart way?
>
> Thanks!
> Nathan
>
> _______________________________________________
> 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/20140303/4ccbdf15/attachment-0001.html>

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

Message: 3
Date: Mon, 03 Mar 2014 17:55:34 +0100
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] list problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello,

I have this :

cons8 n l = n : l
x = cons8 8 [1,2,3]

main = print x

This will be the output:    [8.1.2.3]

Now the problem is how I can take care that the output will be [1,2,3,4,8]
I have to change the function for it.

I tried switching n and L in the function but that will not work.
Or does I have to do x = cons [1,2,3] 8 and make the function like this 
cons8 l n = l : n

Roelof


---
Dit e-mailbericht bevat geen virussen en malware omdat avast! 
Antivirus-bescherming actief is.
http://www.avast.com



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

Message: 4
Date: Mon, 03 Mar 2014 16:59:16 +0000
From: Benjamin Edwards <[email protected]>
To: [email protected]
Subject: [Haskell-beginners]  list problem
Message-ID:
        <can6k4nhxttg-4tv+0xa2qcsf2_bsgcpj+ld8gm7fwpx4ve3...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

The problem is that you don't seem to understand how singly linked lists
work. I would recommend studying this first, then understanding how to
append a value to the end of the list in haskell will probably make a lot
more sense.


>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140303/a86be08f/attachment-0001.html>

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

Message: 5
Date: Mon, 3 Mar 2014 10:00:26 -0700
From: Chris Schneider <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Good way of combining functions of
        type IO (Maybe a)
Message-ID:
        <caghc4ugtujcn35jwnhhl+uno5cqekakln7ojsjdcufqvwce...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I'm a beginner as well, and I explored how to use the maybeT transformer
and wrote it up on my blog across a few posts. Mostly they were just for my
own learning purposes, but maybe you can find something in them too?

http://watchchrislearn.com/blog/2013/11/28/playing-with-the-either-monad/
http://watchchrislearn.com/blog/2013/11/30/using-the-either-monad-inside-another-monad/
http://watchchrislearn.com/blog/2013/11/30/eithert-inside-of-io/
http://watchchrislearn.com/blog/2013/12/01/working-entirely-in-eithert/




On Mon, Mar 3, 2014 at 8:21 AM, David McBride <[email protected]> wrote:

> cabal install maybet
>
> import Control.Monad.Maybe
>
> f1 :: IO (Maybe Int)
> f1 = return . Just $ 1
>
> d2 :: Int -> IO (Maybe String)
> d2 = return . Just . show
>
> blah :: IO (Maybe (Int, String))
> blah = do
>   runMaybeT $ do
>   a <- MaybeT f1
>   b <- MaybeT $ d2 a
>   return (a,b)
>
> Or slightly rewritten:
>
> f1 :: MaybeT IO Int
> f1 = return 1
> -- f1 = fail "why oh why?!?"
>
> d2 :: Int -> MaybeT IO String
> d2 = return . show
>
> blah = do
>   runMaybeT $ do
>
>   a <- f1
>   b <- d2 a
>   return (a,b)
>
>
>
> On Mon, Mar 3, 2014 at 10:10 AM, Nathan H?sken 
> <[email protected]>wrote:
>
>>  Hey,
>>
>> I want to write a function, which is basically a concatenation of
>> functions of type "IO (Maybe a)".
>> When they all where of type "Maybe a", no Problem I would simple use the
>> Maybe monad.
>>
>> func :: Maybe cfunc = do
>>   a <- f1
>>   b <- d2 a
>>   ...
>>
>> but now they are of type "IO (Maybe a)". Is there some way of combing
>> these in a similar smart way?
>>
>> Thanks!
>> Nathan
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
> _______________________________________________
> 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/20140303/10fad149/attachment-0001.html>

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

Message: 6
Date: Mon, 03 Mar 2014 18:04:01 +0100
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] list problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140303/31dee15f/attachment.html>

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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 69, Issue 8
****************************************

Reply via email to