Would love a complete `Person` example :)
Hello; thanks for this lovely library!
I'm trying to wrap my mind around it.
In the README, you start with a Person example; but then quickly jump into ASTs.
My usage isn't actually an AST; it's much more like the Person example. I'm here because I couldn't quite get barbies to work ( see https://github.com/jcpetruzza/barbies/issues/47 ).
In my own hacking, I'm trying something like
data Person h = Person
{ height :: h :# Const Double
, weight :: h :# Const Double
, name :: h :# Const Text
}
person :: Pure # Person
person = Pure $ Person
{ height = Pure $ Const 5.0
, weight = Pure $ Const 1.0
, name = Pure $ Const "name"
}
maybePerson :: Maybe # Person
maybePerson = undefined
what's not clear to me is how to define the maybePerson type. As-is, it doesn't compile. I think I need to somehow adapt the Maybe type to be a kind of Hyper type; but I'm missing exactly how.
I'd love to know how to do this; and then do barbie-style things such as a bmap which takes, say, an Identity # Person and converts it to a Maybe # Person via runIdentity.
Thanks!
Hmm; maybe the answer is this:
data HMaybe a
= HNothing
| HJust (a :# HMaybe)
maybePerson :: HMaybe # Person
maybePerson = HJust $ Person
{ height = HNothing
, weight = HNothing
, name = HJust $ Const "Name"
}
?
I guess I was hoping there was a way to re-use existing types instead of defining my own? But I can live with the fact that there isn't; but I'm sure there's a way to make it work ...
I'm fairly sure there has to be a way to define a kind of ToHyper type that would take a Maybe type as an argument; but I'm struggling to make that work ...
I feel like I'm missing access to a crucial type variable.
I want to write:
data ToHyper :: (Type -> Type) -> AHyperType -> Type where
ToHyper :: f :# ToHyper f -> ToHyper f h
but I somehow need to get out the variable of AHyperType and apply f to it; but I'm not sure how.