[Haskell] Using putStrLn/printf from DLL in GUI application

Krasimir Angelov kr.angelov at gmail.com
Sun Dec 3 06:07:17 EST 2006


withConsole doesn't make much sense. The meaning of
allocConsole/freeConsole is more like showConsole/hideConsole. You may
want to show the console from DllMain when the dll is loaded and to
hide it when it is unloaded. You can't do this with withConsole.

Cheers,
  Krasimir

On 12/2/06, Sven Panne <sven.panne at aedion.de> wrote:
> Am Freitag, 1. Dezember 2006 21:37 schrieb Krasimir Angelov:
> > [...]
> > do allocConsole
> >      .....
> >      .....
> >      putStrLn "Hello, world!"
> >      .....
> >      .....
> >      freeConsole
> > [...]
>
> Having explicit alloc/free pairs can lead to resource leaks in the presence of
> exceptions. Simple solution: Merge both parts into a single function, using
> "bracket" or friends internally:
>
>   withConsole $ do
>      ...
>      putStrLn "I'm exception safe! :-)"
>      ...
>
> Cheers,
>   S.
>


More information about the Haskell mailing list