Since DataKinds (and recently TypeData) I find myself toying more and more with taggging data types with various properties instead of producing variants. One such example is FFI Ptr
. I’d love to have Pointer [ReadOnly, NonNull] a
, but native lists don’t work very well because Pointer [ReadOnly, ReadOnly, ReadOnly] a
is utterly useless.
In practice this could translate to APIs looking like:
peek :: forall (s :: [Property]) (a :: Type) . Ptr s a -> IO a
poke :: forall (s :: [Property]) (a :: Type) .
(ReadWrite ∈ s)
=> Ptr s a
-> a
-> IO ()
So, I wonder what it would take to implement type-level sets. Perhaps I’m thinking too much about it and something like s :: Set [Property]
could work, perhaps with type errors in case of duplication?