There's a BinaryLiterals extension mentioned in the Language.Haskell.Extensions document. The idea is you can say 0b11 == 3
.
> :set -XBinaryLiterals
Some flags have not been recognized: -XBinaryLiterals
Binary literals can be written in one of the following formats: b'value' , B'value' or 0bvalue , where value is a string composed by 0 and 1 digits. Binary literals are interpreted as binary strings, and are convenient to represent VARBINARY, BINARY or BIT values.
A binary literal is a number that is represented in 0s and 1s (binary digits). Java allows you to express integral types (byte, short, int, and long) in a binary number system. To specify a binary literal, add the prefix 0b or 0B to the integral value.
Binary integer literals (0b…) are supported in the C++ language but not in the C language.
Binary literals begin with a leading 0b or 0B, followed by binary digits (0-1). All of these literals produce integer objects in program code; they are just alternative syntax for specifying values. The built-in calls hex(I), oct(I), and bin(I) convert an integer to its representation string.
According to this https://ghc.haskell.org/trac/ghc/ticket/9224, it is slated for release in version 7.10.1. This doesn't seem to be released yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With