You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most of the functions will only have a few Haskell-level errors and library users do not need error interoperability across the entire library. Making each distinct function have its own error type will also allow for better documentation.
Unfortunately Botan API does not version errors, so those will have to be passed around as CInts without clarification.
Organization
botan-low should work over pointers and sizes, not Haskell datatypes.
By creating a basic datatype like Bytes = Bytes (Ptr Word8) Int you can leave allocations out of this level. Conversions to such datatypes are generic and you don't need to unbox anything, the simplifier will inline the datatype for you.
botan-low can store algorithm names raw using MagicHash: the format is Ptr "Foo\0"#, the result is a C string.
Library structure
Preludes and default extensions are bad practices.
It's easy to add an extra import to a custom prelude, it's hard to remove it, so over time these things bloat, slowing down everything and making the library harder to navigate. Consider creating special modules for functions that need to be shared and inlining function wrappers.
Algorithm enumerations may be harmful on the high level, as the C library may not support certain algorithms or support ones you didn't expect.
Tests do not need to rely on packages they're in, you can share the source files instead.
This also allows you to test internal modules without exposing them.
The text was updated successfully, but these errors were encountered:
Not really. Default extension lists are great, because listing all common extensions that pretty much everyone enables (or are part of the GHC2021) at the top of each module is annoying to write and unnecessary noise to read.
Error handling
The library does not need to throw exceptions on any level.
The control flow when interfacing with a C library inevitably unrolls to
so you can skip all the busywork and just write the following instead
Error unification makes the API more complex.
Most of the functions will only have a few Haskell-level errors and library users do not need error interoperability across the entire library. Making each distinct function have its own error type will also allow for better documentation.
Unfortunately Botan API does not version errors, so those will have to be passed around as
CInt
s without clarification.Organization
botan-low
should work over pointers and sizes, not Haskell datatypes.By creating a basic datatype like
Bytes = Bytes (Ptr Word8) Int
you can leave allocations out of this level. Conversions to such datatypes are generic and you don't need to unbox anything, the simplifier will inline the datatype for you.botan-low
can store algorithm names raw usingMagicHash
: the format isPtr "Foo\0"#
, the result is a C string.Library structure
Preludes and default extensions are bad practices.
It's easy to add an extra import to a custom prelude, it's hard to remove it, so over time these things bloat, slowing down everything and making the library harder to navigate. Consider creating special modules for functions that need to be shared and inlining function wrappers.
Algorithm enumerations may be harmful on the high level, as the C library may not support certain algorithms or support ones you didn't expect.
Tests do not need to rely on packages they're in, you can share the source files instead.
This also allows you to test internal modules without exposing them.
The text was updated successfully, but these errors were encountered: