[Haskell-cafe] What is a Haskell way to implement flags?

Brandon Allbery allbery.b at gmail.com
Tue Feb 19 18:07:09 CET 2013


On Tue, Feb 19, 2013 at 10:11 AM, Branimir Maksimovic <bmaxa at hotmail.com>wrote:

>  In C usual way is to set some bit in integer variable by shifting or
> oring,
> and than check flag integer variable by anding with particular flag value.
> What is Haskell way?
>

You can do that, but a somewhat more idiomatic way would be a list (or,
slightly less conveniently but more accurately, a Data.Set) of constructors
from a flags ADT.

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130219/74f66610/attachment.htm>


More information about the Haskell-Cafe mailing list