Skip to content

Achieve feature parity with the C++ library #108

@jorisdral

Description

@jorisdral

The Botan C++ library has many features, some of which can be configured to be included or excluded, and some features are linked to the OS.We should make sure that the Haskell libraries achieve feature parity with all versions of the C++ library.

This issue is tied to #100: let's assume that each of the Haskell packages support multiple versions of the C++ library.

Let's first assume how to achieve feature parity with a single version of the C++ library. The API of the FFI header file that is provided by the C++ library is the same regardless of which features are enabled. If entities (functions/globals/types) are used for features that are disabled, then these functions will return an error code. So, it should suffice in this case to create Haskell bindings for all entities in the header file. If a Haskell binding is used for a feature that is disabled in the C++ library, then the Haskell bindings will propagate the error code.

Achieving feature parity with multiple versions of the C++ library is slightly more involved. The C++ library uses semantic versioning, and since we only support Botan-3 in the Haskell packages, we can assume that newer versions do not make incompatible API changes. Still, new versions can add new functionality, like new functions, which we should create bindings for.

There are some choices to make here, namely (i) do we conditionally export a binding, or (ii) do we always export a binding but throw an error if the version of the C++ library is not compatible?

Option (i):

#if CONDITION
foreign import ... "foo" foo :: IO CInt
#endif

Option (ii):

foo :: IO CInt
#if SOME_VERSION_CONDITION
foo = foo'
#else
foo = error "foo not available!"
#endif

#if SOME_VERSION_CONDITION
foreign import ... "foo" foo' :: IO CInt
#endif

Moreover, we can decide to use option (i) in every Haskell package, or we can choose to use option (ii) in every Haskell package, or maybe we want to use option (i) only in botan-bindings and option (ii) everywhere else.

Most importantly, we currently only support a set of base features that have been available since version 3.0.0 of the C++ library, which is shown to compile well since we test with all available 3.MINOR versions in CI. Still, we are probably missing bindings for new entities that have been added in newer versions of the C++ library. We should support all these features.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    botanRelated to the botan packagebotan-bindingsRelated to the botan-bindings packagebotan-lowRelated to the botan-low packageenhancementNew feature or requestpriority: medium

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions