type-level-sets
type-level-sets copied to clipboard
Need some guidance / documentation
I'm sorry to say I'm a bit mystified by the API. I would like to use this to build sets of error types. Suppose I had a value of type s
, where s
was a set of error types. How do I write functions to (1) lift an error type into a set type: Member e s => e -> s
, and (2) decompose an error set value: Member e s => s -> Either e (Delete e s)
? Am I barking up the wrong tree?
Hi @ddssff ,
The way this library works is that a type level set is a data type Set xs
where xs
is a list of a type level things,. For example, you can have type level sets of nats as shown in the example here: https://hackage.haskell.org/package/type-level-sets
If you already have some type s
then it will need to be something that is promotable so that the constructors of s
can be put inside type level sets. Do you have a particular s
in mind?
What we ended up doing is writing this: https://github.com/seereason/sr-extra/blob/master/Extra/Errors.hs. It lets us create a type with is the sum of a set of named (error) types, and manipulate values of that sum type. The only thing missing is sorting of the type list, but I see code around that could do it.