Seems like you'd want x <- getArgs and x == ["debug"] rather than the
irrefutable pattern match.

On Sun, Dec 26, 2010 at 3:04 PM, Michael Snoyman <[email protected]>wrote:

> I think something like this would work:
>
> myFlag = unsafePerformIO $ do
>    [x] <- getArgs
>    return $ x == "debug"
>
> In general, unsafePerformIO should be avoided, but this is one of
> those situations where we can give you a pass ;).
>
> Michael
>
> On Sun, Dec 26, 2010 at 9:53 PM,  <[email protected]> wrote:
> > Hi,
> >
> > I have a program with a debug flag in it (Strangely I've yet to be
> > able to write bug-free code).  I'd like to change the state of the
> > debug flag based on command line args.
> >
> > I looked at IOVar but that would cause all the pure procedures to get
> > swallowed by the IO Monad.
> >
> > Is a better way to get this behavior ?
> >
> > Thanks,
> >
> > Brian
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to