
19 Feb
2013
19 Feb
'13
4:59 p.m.
Quoth Branimir Maksimovic
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?
Of course you may do the very same thing, if you like. I think if there's only one of these for the entire program, most Haskell programmers would use a Boolean value, as the space you save with a single bit is of too little consequence to bother with bit twiddling in Haskell. The various flags that belong together might be housed in a `record'. Or, in some contexts a list of an algebraic type might be useful - like, "if elem FlagDebug flags", or "if any (flip elem flags) [FlagDebug, FlagVerbose]" Donn