You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicStatereduceClassDeclaration(
ClassDeclarationnode,
Statename,
Maybe<State> _super,
ImmutableList<State> elements
)
where of course ClassDeclaration is shaped like
classClassDeclaration(
BindingIdentifiername,
Maybe<Expression> _super,
ImmutableList<ClassElement> elements
)
There is a guarantee provided by the director, but not the type system, that the fields of the node and the noninitial arguments of the method line up, in the sense that node._super.isJust() == _super.isJust(), node.elements.length == elements.length, etc.
The fact that this isn't enforced by the type system leads to a lot of unchecked .fromJust()s. We could avoid this by defining, for each node type, a node-with-associated-data type along the lines of
and then making the signature of methods in Reducer<State> be
publicStatereduceClassDeclaration(
ClassDeclarationWithT<State> state
)
This does have the downside that you don't get a reference to the original node, which the LazyCloneReducer among other interfaces wast - for example, you need the original node to look up its location in the data structure provided by ParserWithLocation. I suppose it could always be passed as a second argument for those cases.
You can of course automatically convert between reducers of this type and reducers of the existing type, though going from reducers of the existing type to reducers of this type requires having all those unchecked .fromJust()s.
The text was updated successfully, but these errors were encountered:
Currently the reducer has methods which look like
where of course
ClassDeclaration
is shaped likeThere is a guarantee provided by the director, but not the type system, that the fields of the node and the noninitial arguments of the method line up, in the sense that
node._super.isJust() == _super.isJust()
,node.elements.length == elements.length
, etc.The fact that this isn't enforced by the type system leads to a lot of unchecked
.fromJust()
s. We could avoid this by defining, for each node type, a node-with-associated-data type along the lines ofand then making the signature of methods in
Reducer<State>
beThis does have the downside that you don't get a reference to the original node, which the LazyCloneReducer among other interfaces wast - for example, you need the original node to look up its location in the data structure provided by ParserWithLocation. I suppose it could always be passed as a second argument for those cases.
You can of course automatically convert between reducers of this type and reducers of the existing type, though going from reducers of the existing type to reducers of this type requires having all those unchecked
.fromJust()
s.The text was updated successfully, but these errors were encountered: