f# - Calling pretty-printer function from the base class of an AST -


i'm porting c# project f# , there's rather large type hierarchy represents sql ast. on base type of hierarchy, sqlnode, tostring overridden call pretty printer operates on sqlnode's subtypes. this:

type sqlnode =     override x.tostring() = sqlprinter.print x  ... // bunch of node types deriving sqlnode ...  type sqlprinter =     static member print(node: sqlnode) =         match node         | :? sqlselect -> ...         | :? sqlinsert -> ...         // etc. 

how port f# without putting formatting logic in nodes themselves?


Comments