clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.4k stars 149 forks source link

Ditch `ContT` from `clash-ffi` #2558

Closed kleinreact closed 8 months ago

kleinreact commented 11 months ago

This PR simplifies the API of clash-ffi by removing the monadic ContT transformer reducing the interface to some basic IO.

ContT is currently only used in clash-ffi for creating a unified interface for Foreign.Marshal.Alloc.alloca (stack allocation) and Foreign.Marshal.Alloc.malloc (heap allocation), which have different interfaces in base on purpose for reflecting the different characteristics of the stack and the heap. However, the introduced uniformization does not unify stack and heap usage in clash-ffi. The user still has to choose among different API calls depending on where objects have to be allocated. Thus, ContT really only provides a uniform type interface for both allocation methods, which is a weak achievement compared to the API modifications resulting from the additional monadic context it introduces.

Overall, the usage of ContT comes with the following downsides:

Therefore, we propose to ditch ContT from clash-ffi.

This is a breaking API change, which is reflected in a version number increment.