Hi there,
First, congratulations on a really cool package. I’m excited to explore whether it’s a solution to this problem we’ve encountered while building the Semantic framework: we want to generate syntax trees that have shape functors attached to them, but working with these structures in a manner that’s comparably fluent to plain-old-data-types is tricky.
I’ve been experimenting with a JSON grammar, and have run into a problem: I can’t figure out how to specify that one syntax node should contain a list of others. I have these two types:
newtype EscapeSequence (f :: Type -> Type) = EscapeSequence { text :: Ap10 Text f }
deriving stock (Eq, Ord, Read, Show, Generic, Generic1)
deriving anyclass (NFData, Hashable)
deriving (Portray, Diff) via Wrapped Generic (EscapeSequence f)
deriving (Foldable10, Traversable10, Constrained10 c, Functor10, Applicative10, Representable10, Update10) via Wrapped1 Generic1 EscapeSequence
newtype StringContent (f :: Type -> Type) = StringContents { contents :: EscapeSequence f }
deriving stock (Eq, Ord, Read, Show, Generic, Generic1)
deriving anyclass (NFData, Hashable)
deriving (Portray, Diff) via Wrapped Generic (StringContent f)
deriving (Foldable10, Traversable10, Constrained10 c, Functor10, Applicative10, Representable10, Update10) via Wrapped1 Generic1 StringContent
and I would like StringContent to contain an [EscapeSequence f], or some sort of structure that allows one StringContent to hold multiple EscapeSequence values. (Note that in this case I could just remove the type parameter from EscapeSequence, but lists etc. appear elsewhere in syntax where this wouldn’t be an option.) I’ve tried using a plain [EscapeSequence f] field, which since [] is not Representable, precludes using Representable10 and Update10. I’ve tried using Cofree, and also tried using Compose and :.: and ListT to glom on an additional list-layer. None of these things seem to work—the only solution I’ve found is to remove the Representable10 and Update10 derivings. While I could dispense with them, it would be a huge win if I could retain that typeclass machinery, as I’d love to use ten-lens. Do you have any suggestions here?
Hi there,
First, congratulations on a really cool package. I’m excited to explore whether it’s a solution to this problem we’ve encountered while building the Semantic framework: we want to generate syntax trees that have shape functors attached to them, but working with these structures in a manner that’s comparably fluent to plain-old-data-types is tricky.
I’ve been experimenting with a JSON grammar, and have run into a problem: I can’t figure out how to specify that one syntax node should contain a list of others. I have these two types:
and I would like
StringContentto contain an[EscapeSequence f], or some sort of structure that allows oneStringContentto hold multipleEscapeSequencevalues. (Note that in this case I could just remove the type parameter fromEscapeSequence, but lists etc. appear elsewhere in syntax where this wouldn’t be an option.) I’ve tried using a plain[EscapeSequence f]field, which since[]is notRepresentable, precludes usingRepresentable10andUpdate10. I’ve tried usingCofree, and also tried usingComposeand:.:andListTto glom on an additional list-layer. None of these things seem to work—the only solution I’ve found is to remove theRepresentable10andUpdate10derivings. While I could dispense with them, it would be a huge win if I could retain that typeclass machinery, as I’d love to useten-lens. Do you have any suggestions here?