https://kotlinlang.org logo
#functional
Title
# functional
t

tschuchort

03/15/2020, 10:41 PM
I'm trying to come up with a good design for an AST, but the problem is that I need to construct it in two different ways from two different source data structures. I'm unsure how to make it readable and maintainable without a ton of boilerplate. Does anyone have any tips on this?
r

raulraja

03/16/2020, 10:02 AM
Not sure if you have already looked into Kastree but they model Kotlin in an AST with an ADT of sealed classes.
t

tschuchort

03/16/2020, 10:13 PM
I know how to declare an ADT of course. The hard part is how to construct values of the AST or rather how to declare the AST in such a way that it will be easy to construct incrementally (reusing common code) and lazily from 2 different source data structures with non-local knowledge. Kastree is homomorphic to Psi and completely strict, that makes the whole thing much easier.
3 Views