4 ms·
There’s no difference in this case—looks like an oversight. “<>” is the Monoid “append” operator (e.g., concat lists, union sets, compose functions). If you loo
by evincarofautumn 10y ago
There’s no difference in this case—looks like an oversight. “<>” is the Monoid “append” operator (e.g., concat lists, union sets, compose functions). If you look in JIT.hs[1], you’ll see that there’s an instance of Monoid that just calls “.|.” (bitwise OR):
instance Monoid ProtOption where
mempty = protNone
mappend (ProtOption a) (ProtOption b) = ProtOption (a .|. b)
[1]: https://github.com/sdiehl/tinyjit/blob/master/src/JIT.hs https://github.com/sdiehl/tinyjit/blob/master/src/JIT.hs
- mrkgnao 10y agoThere is no canonical monoidal operation on booleans (just as the case is in any arbitrary ring), so I'd guess using the bitwise operators explicitly is good for disambiguation.
- evincarofautumn 10y agoYes and no—in practice in Haskell we tend to choose the most convenient instance and wrap things in newtypes to get at other instances. Writing code using generic operations (Monoid, Functor, Foldable) makes it easier to refactor datatypes later—coding to the interface and not the implementation, and all that. The bitwise OR operation makes sense for ProtOption because it’s basically a set.
- mrkgnao 10y agoThat's true, for bitflag-like things OR does make sense.