How would I go about deriving the function
getField :: (Generic a, HasDatatypeInfo a) => Proxy (name :: Symbol) -> a -> b
to project a field from an arbitrary record using a type-level string (Symbol), using the generics-sop library?
This is…
Is there a Haskell library providing (or assisting in writing) generic isomorphism between a sum type and an associated heterogenous sum type?
Take the following sum type,
data TR = TR_Index | TR_Inner R
Now we associate it with a heterogenous sum…
In generics-sop, what is the idiomatic way to generically create a sum constructor value given both its position (index) and the product value of its args?
For example consider,
-- This can be any arbitrary type.
data Prop = Name String | Age Int |…
I'm trying to use All from generics-sop to constrain a list of types. Everything works as expected with simple classes like All Typeable xs, but I'd like to be able to do something like the following:
class (Typeable a) => TestClass (a ::…
I've written the following function using generics-sop. What it does, is given a value of a product type, goes through all it's members, applies a function to all those members, and spits out a list of the results:
import Generics.SOP qualified as…
The NS type from sop-core creates an interesting conundrum. In S :: NS f xs -> NS f (x ': xs) where xs ~ '[] means that the argument to the S is inhabited. Yet Haskell's case matching forces me to match on it. Is there a resolution to this…
I've been using generics-sop quite successfully so far, but for one use case I'd like to get the names of record fields.
The types I'm working with are product types, and I can use the constraint IsProductType a xs to enforce this.
Doing so I end up…
I would like to produce a rose tree representation (called Header in the following) of a data type using generics-sop, but I got stuck at one detail; specifically, how to pass type information "one level down" within the implementation of mkAnonProd…