caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] [ANN] BitMasks 1.0.0
@ 2014-03-18 21:01 David Allsopp
  2014-03-18 21:30 ` Yaron Minsky
  0 siblings, 1 reply; 2+ messages in thread
From: David Allsopp @ 2014-03-18 21:01 UTC (permalink / raw)
  To: OCaml List

Firstly, many thanks for the various replies to my earlier request for
pointers and guidance on packaging earlier this month.

I'm pleased to announce the release of BitMasks 1.0.0. This library is
designed primarily with C bindings in mind and is yet another solution to
the "how do we manipulate integer bitmask flags functionally" problem. So,
given an integer where bit 0 means something, bit 1 means something else and
bit 2 yet something further, this library allows that to be exposed as type
t = Foo | Bar | Baz and have the integer be constructed as though it were a
set.

This implementation has three key features:
* Underlying type is provided through a functor (so int or int64 or indeed
an arbitrary precision integer can be used)
* There's no copying, so the original integer can still be used (either
internally or, at the whim of the programmer, the integer can be exposed).
This has significant advantages over, for example, returning the a list of
the bits which are set.
* The resulting signature is compatible with Set.S in the standard library

Project home: http://forge.ocamlcore.org/projects/bitmasks/
Repository: https://github.com/meta-stack/bitmasks
OPAM package: bitmasks

The source includes a full example. I believe having looked at other code
out there that Core follows a similar philosophy.

The original motivation for this library was to provide a sane handling for
the myriad masks of information returned by ODBC's SQLGetInfo function, but
I've found it be useful in other bindings as well (particularly for bindings
for some Raspberry Pi components which I hope to release soon) and hope
others may do too.

Happy functional bit set manipulating!


David


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] [ANN] BitMasks 1.0.0
  2014-03-18 21:01 [Caml-list] [ANN] BitMasks 1.0.0 David Allsopp
@ 2014-03-18 21:30 ` Yaron Minsky
  0 siblings, 0 replies; 2+ messages in thread
From: Yaron Minsky @ 2014-03-18 21:30 UTC (permalink / raw)
  To: David Allsopp; +Cc: OCaml List

[-- Attachment #1: Type: text/plain, Size: 2470 bytes --]

You might be interested also in the Flags module in Core_kernel, which aims
to serve a similar purpose.

https://ocaml.janestreet.com/ocaml-core/111.03.00/doc/core_kernel/#Flags
https://github.com/janestreet/core_kernel/blob/master/lib/flags.ml
https://github.com/janestreet/core_kernel/blob/master/lib/flags.mli
https://github.com/janestreet/core_kernel/blob/master/lib/flags_intf.ml

y


On Wed, Mar 19, 2014 at 8:01 AM, David Allsopp <dra-news@metastack.com>wrote:

> Firstly, many thanks for the various replies to my earlier request for
> pointers and guidance on packaging earlier this month.
>
> I'm pleased to announce the release of BitMasks 1.0.0. This library is
> designed primarily with C bindings in mind and is yet another solution to
> the "how do we manipulate integer bitmask flags functionally" problem. So,
> given an integer where bit 0 means something, bit 1 means something else
> and
> bit 2 yet something further, this library allows that to be exposed as type
> t = Foo | Bar | Baz and have the integer be constructed as though it were a
> set.
>
> This implementation has three key features:
> * Underlying type is provided through a functor (so int or int64 or indeed
> an arbitrary precision integer can be used)
> * There's no copying, so the original integer can still be used (either
> internally or, at the whim of the programmer, the integer can be exposed).
> This has significant advantages over, for example, returning the a list of
> the bits which are set.
> * The resulting signature is compatible with Set.S in the standard library
>
> Project home: http://forge.ocamlcore.org/projects/bitmasks/
> Repository: https://github.com/meta-stack/bitmasks
> OPAM package: bitmasks
>
> The source includes a full example. I believe having looked at other code
> out there that Core follows a similar philosophy.
>
> The original motivation for this library was to provide a sane handling for
> the myriad masks of information returned by ODBC's SQLGetInfo function, but
> I've found it be useful in other bindings as well (particularly for
> bindings
> for some Raspberry Pi components which I hope to release soon) and hope
> others may do too.
>
> Happy functional bit set manipulating!
>
>
> David
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 3775 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-18 21:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-18 21:01 [Caml-list] [ANN] BitMasks 1.0.0 David Allsopp
2014-03-18 21:30 ` Yaron Minsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).