[Haskell-cafe] wxHaskell not in scope

Daniel Fischer daniel.is.fischer at web.de
Fri Apr 17 08:16:58 EDT 2009


Am Freitag 17 April 2009 01:37:25 schrieb Tsunkiet Man:
> Hello,
>
> what you suggested worked! Im very happy with it. However another error
> suddenly came up. It sais the last statement in a 'do' must be an
> expression, he is refering to line 41:45
>
> I change my code to this:
>
>                     on (menu exit) := close f,
>                     on (menu open) := onOpen f dt vFile ]
>
>             return ()
>
>             where
>                 onOpen :: Frame a -> staticText c -> Var b -> IO ()
>                 onOpen frame stat var = do   file <- fileOpenDialog frame
> False True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle
> bestanden (*.*)",["*.*"])] "" ""
>                                         case file of
>                                             Nothing ->      return ()
>                                             Just file ->    set stat [text
>
> := "HELLO"]
>
>                                                             return ()


In the "Just file" case, you want to have two IO-actions. If you don't use (>>=) or (>>) 
to chain them together, you must put them in a do-block, so

    case file of
      Nothing -> return ()
      Just file -> do set stat [text := "HELLO"]
                      return ()

But I think you can omit the return () in that branch anyway, set foo bar should have the 
correct type already.

>
> As far as I can tell, if the file is nothing it will return something of IO
> () and if the file is something it will return something of IO (). So that
> error is kind of strange in my opinion. Do you know what caused it?
>
> Thanks for your help!
>



More information about the Haskell-Cafe mailing list