Botan bindings devlog

Weekly meeting notes

A sizeable update has been posted to the Improving memory / memalloc thread.

Leo

  • Published and updated memalloc repo
  • Updated the Improving Memory thread with a deep dive explaining the new typeclass hierarchy
  • Focused mostly on re-creating the most-used APIs from memory
    • Successfully split ByteArray/Access up into Address, Layout and Allocator plus various allocation types
      • Allocation types are Handle, Ref, Array, and Pointer
      • Non-specific allocation type-classes include Castable and Retainable
    • Reached parity with ByteArray by implementing ByteArray.allocRet using Allocator.alloc
    • withAddress neé ByteArrayAccess.withByteArray is part of Allocator now but might become an allocation access class
    • Combined with Array, we have achieved our core goal of re-creating the ByteArray/Access class API
      • We still need to implement the functions and instances that use them though
  • Created an example of using ImplicitParams to hide the alr :: Allocator alr argument to better recover the original memory interface
    • There are a few other methods of doing this
      • eg if the monad supplies the allocator
      • or if the resulting allocation or data structure keeps a reference to its allocator
      • or if the allocator is a singleton so we can just infer it / use a Proxy
  • Implemented the Std allocator that uses GHC’s wrapping of the C malloc and free
    • It isn’t finished yet but I used it to illustrate the problem that I’ll be dealing with next
    • Basically Allocation is of kind * but Handle, Reference, Pointer, Array are all of kind * -> *
    • But we need to allow both allocating eg a polymorphic Ptr a but also something like a monomorphic ByteString that is secretly a Ptr Word8 that is secretly an Addr#
    • But I think I have a solution via parametric allocators / allocations - this is my main goal this week

Joris

  • Last week continued looking into using hs-bindgen
  • Also was working w/ autoconf (legacy way of configuring packages w/ system dependencies) for build scripting - but now looking into cabal hooks instead for
    • Main reason wanted to do this was because he noticed he was trying to write actual programs in autoconf instead of scripts - eg parsing c macros, significant logic, at that point just use cabal hooks and write a haskell program
    • This makes the build scripts way more accessible to other devs
  • also going to look at the memalloc stuff (thx!)
  • main task is hs-bindgen

Jose

  • Unable to attend

Outcome

This week:

  • Leo
    • Have a 1:1 with Jose
    • Continue to work on memalloc in order to use it in botan-low for managing allocation (and in botan in the future)
    • Focus on parametric allocators / allocations
    • Update the memalloc repo again
    • Update the Improving Memory thread again
  • Joris
    • Continue working on hs-bindgen
    • Look into cabal-hooks
    • Read up on the new memalloc stuff

Until next time!

7 Likes