Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Pb with toggleActionNew (Pierre Michallet)
   2. Re:  Pb with toggleActionNew (Brandon Allbery)
   3. Re:  Pb with toggleActionNew (Nick Vanderweit)
   4. Re:  simple sound playback (Gnu/Linux) (Stephen Tetley)


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

Message: 1
Date: Sun, 22 Jul 2012 16:46:56 +0200
From: "Pierre Michallet" <p.michal...@free.fr>
Subject: [Haskell-beginners] Pb with toggleActionNew
To: "beginners haskell" <beginners@haskell.org>
Message-ID: <8F8862782F1248EF96C8E6DFD996293F@medione9995867>
Content-Type: text/plain; charset="iso-8859-1"

I am trying to become acquainted with both haskell and Gtk thru the writing of 
small pieces of code exercising some Gtk functions.
Having had problems with the ToggleEntry function (unable to get the 
checked/non checked status - refer to chapter 7.2 of the Gtk2HS tutorial) I 
have tried to understand
the toggleAction thing.
So I have written this :

import  Graphics.UI.Gtk.ActionMenuToolbar.ToggleAction
...

togls::[ToggleAction]
togls = let stone = toggleActionNew "STON" "Stones number" Nothing  Nothing  
(myTog stone)       
               deste = toggleActionNew "DEST" "Destination" Nothing Nothing  
(myTog deste)      
              state = toggleActionNew "STAT" "Board status" Nothing Nothing  
(myTog state)
          in [stone,deste,state]

myTog::ToggleAction->IO()
myTog ta =  putStrLn ("The name of the action is " ++ (toggleActionName ta))   

The compiler is not happy with this and sends back the following:

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

The function 'toggleActionNew' is applied to five arguments but its type 'String
                                                                                
                      ->String
                                                                                
                      ->Maybe String
                                                                                
                      -> Maybe stockId
                                                                                
                      ->IO ToggleAction
has only four.

-------------------------------------------------------------------------------------------------------------------------------------------
To me, stone has 4 parameters ("STON", "Stones number", Nothing,Nothing) and a 
result (myTog stone) as in the definition given by the compiler.
I am using ghc-7.0.3
                gthk+-bundle_2.16.2-20090601_win32
                gtk-0.12.3.1 documentation

I am certainly missing something obvious to everybody but I could not solve it 
, so I would appreciate any help on this topic.

Thanks in advance

p.michal...@free.fr
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120722/cb072eb2/attachment-0001.htm>

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

Message: 2
Date: Sun, 22 Jul 2012 11:22:11 -0400
From: Brandon Allbery <allber...@gmail.com>
Subject: Re: [Haskell-beginners] Pb with toggleActionNew
To: Pierre Michallet <p.michal...@free.fr>
Cc: beginners haskell <beginners@haskell.org>
Message-ID:
        <CAKFCL4Xd+8GJJu=luiwqhmbvueydonk0oquxxb7ee759jue...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sun, Jul 22, 2012 at 10:46 AM, Pierre Michallet <p.michal...@free.fr>wrote:

> **
> To me, stone has 4 parameters ("STON", "Stones number", Nothing,Nothing)
> and a result (myTog stone) as in the definition given by the compiler.
>

Yes.  So why are you trying to provide the result that it's supposed to
produce?

-- 
brandon s allbery                                      allber...@gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120722/ce35e86e/attachment-0001.htm>

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

Message: 3
Date: Sun, 22 Jul 2012 15:13:30 -0600
From: Nick Vanderweit <nick.vanderw...@gmail.com>
Subject: Re: [Haskell-beginners] Pb with toggleActionNew
To: beginners@haskell.org
Message-ID: <6369472.JAMQu0YQAV@euler>
Content-Type: text/plain; charset="us-ascii"

Besides the fact that you are trying to pass the result of toggleActionNew as 
an argument, you're going to end up with problems regarding the type signature 
of togls when you try to invoke toggleActionNew, whose type signature is:

toggleActionNew :: String
                -> String
                -> Maybe String 
                -> Maybe String 
                -> IO ToggleAction

So it's a function that, when passed its four arguments, yields an IO 
ToggleAction. One of the important aspects of the IO monad is that it can't be 
(safely) escaped, so unlike many monads, there isn't a function:

escapeIO :: IO a -> a *

This is how the type system enforces that your Int -> Int functions can't 
write to the hard drive, or accept input from stdin, for instance. The only 
way to capture the result of an (IO a) is to use >>= and get another (IO b). 
This means that your type signature for togls is impossible, and it appears 
you should instead try for:

togls :: IO [ToggleAction]


In short: rethink what the possible types are, and don't misinterpret the 
result of a function as one of its arguments.


- Nick


* Actually, this function does exist. It is called unsafePerformIO in 
System.IO.Unsafe, and you really shouldn't use it unless you know what you are 
doing.

On Sunday, July 22, 2012 04:46:56 PM Pierre Michallet wrote:
> I am trying to become acquainted with both haskell and Gtk thru the writing
> of small pieces of code exercising some Gtk functions. Having had problems
> with the ToggleEntry function (unable to get the checked/non checked status
> - refer to chapter 7.2 of the Gtk2HS tutorial) I have tried to understand
> the toggleAction thing.
> So I have written this :
> 

> import  Graphics.UI.Gtk.ActionMenuToolbar.ToggleAction
> ...
> 
> togls::[ToggleAction]
> togls = let stone = toggleActionNew "STON" "Stones number" Nothing  Nothing 
> (myTog stone) deste = toggleActionNew "DEST" "Destination" Nothing Nothing 
> (myTog deste) state = toggleActionNew "STAT" "Board status" Nothing Nothing
>  (myTog state) in [stone,deste,state]
> 
> myTog::ToggleAction->IO()
> myTog ta =  putStrLn ("The name of the action is " ++ (toggleActionName ta))
> 
> The compiler is not happy with this and sends back the following:
> 
> ----------------------------------------------------------------------------
> ---------------------------------------------------------------
> 
> The function 'toggleActionNew' is applied to five arguments but its type
> 'String ->String ->Maybe String -> Maybe stockId ->IO ToggleAction has only
> four.
> 
> ----------------------------------------------------------------------------
> --------------------------------------------------------------- To me, stone
> has 4 parameters ("STON", "Stones number", Nothing,Nothing) and a result
> (myTog stone) as in the definition given by the compiler. I am using
> ghc-7.0.3
>                 gthk+-bundle_2.16.2-20090601_win32
>                 gtk-0.12.3.1 documentation
> 
> I am certainly missing something obvious to everybody but I could not solve
> it , so I would appreciate any help on this topic.
> 
> Thanks in advance
> 
> p.michal...@free.fr



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

Message: 4
Date: Sun, 22 Jul 2012 23:02:45 +0100
From: Stephen Tetley <stephen.tet...@gmail.com>
Subject: Re: [Haskell-beginners] simple sound playback (Gnu/Linux)
To: Christopher Howard <christopher.how...@frigidcode.com>
Cc: Haskell Beginners <beginners@haskell.org>
Message-ID:
        <cab2tprd5qygzkt0ydd_psy4erus5tmfwmw1zmwxmppimjqr...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Christopher

I'm not sure its the simplest option, but OpenAL seems popular for games.



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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 49, Issue 26
*****************************************

Reply via email to