Seems like you'd want x <- getArgs and x == ["debug"] rather than the irrefutable pattern match.<br><br><div class="gmail_quote">On Sun, Dec 26, 2010 at 3:04 PM, Michael Snoyman <span dir="ltr"><<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I think something like this would work:<br>
<br>
myFlag = unsafePerformIO $ do<br>
[x] <- getArgs<br>
return $ x == "debug"<br>
<br>
In general, unsafePerformIO should be avoided, but this is one of<br>
those situations where we can give you a pass ;).<br>
<font color="#888888"><br>
Michael<br>
</font><div><div></div><div class="h5"><br>
On Sun, Dec 26, 2010 at 9:53 PM, <<a href="mailto:briand@aracnet.com">briand@aracnet.com</a>> wrote:<br>
> Hi,<br>
><br>
> I have a program with a debug flag in it (Strangely I've yet to be<br>
> able to write bug-free code). I'd like to change the state of the<br>
> debug flag based on command line args.<br>
><br>
> I looked at IOVar but that would cause all the pure procedures to get<br>
> swallowed by the IO Monad.<br>
><br>
> Is a better way to get this behavior ?<br>
><br>
> Thanks,<br>
><br>
> Brian<br>
><br>
><br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>