LLVM-22 removes all Type and Value creation functions that rely on a global Context. This forces me to make Contexts explicit in the llvm-tf package. Now I had the crazy idea to turn the Contexts into type parameters like so: {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE KindSignatures #-} module LLVM.Core.CodeGenTest where import qualified LLVM.FFI.Core as FFI import Foreign.ForeignPtr (ForeignPtr, withForeignPtr) import Foreign.C.String (withCString) import Data.Int (Int64) newtype Value (context :: ForeignPtr FFI.Context) a = Value FFI.ValueRef This would allow me to define functions like "add" that ensure that both operands and the result are allocated in the same Context: newtype CodeGenFunction (context :: ForeignPtr FFI.Context) r a = CodeGenFunction (IO a) add :: Value ctx a -> Value ctx a -> CodeGenFunction ctx r (Value ctx a) However, that crazy idea stops working when I actually try to construct a Value: int64Value :: forall ctx. Int64 -> IO (Value ctx Int64) int64Value @context n = withForeignPtr context $ \ctx -> withCString (show n) $ \cstr -> do typ <- FFI.intTypeInContext ctx 64 fmap Value $ FFI.constIntOfString typ cstr 10 GHC-10.0 rejects with: • Illegal term-level use of the type variable ‘context’ Is it expected that this would work with further extensions from the Dependent Haskell roadmap? With what extensions? Or is it already possible with todays extensions?