ryukzak / nitta

BSD 3-Clause "New" or "Revised" License
21 stars 6 forks source link

Replace recursive synthesis tree via flat Map #241

Open ryukzak opened 1 year ago

ryukzak commented 1 year ago

Motivation:

Current:

data Tree m tag v x t = Tree
    { sID :: Sid
    , sState :: SynthesisState m tag v x t
    , sDecision :: SynthesisDecision (SynthesisState m tag v x t) m
    , sSubForestVar :: TMVar [Tree m tag v x t]
    -- ^ lazy mutable field with different synthesis options and sub nodes
    }

Which allow to represent the following synthesis tree, where sSubForestVar will evaluated on request:

What to need to change here (naming and detail may variate, also we need to estimate what is better: Map or HashMap for our task):

data Tree m tag v x t = TVar (Map Sid Node)

data Node = Node
    { sID :: Sid
    , sState :: SynthesisState m tag v x t
    , sDecision :: SynthesisDecision (SynthesisState m tag v x t) m
    }

Which represent the same tree in the following way:

M.fromlist [
    ("-", A),
    ("-1", B),
    ("-1-1", C),
    ("-1-2", D),
    ("-2", E),
    ("-2-1", F),
    ("-2-2", G),
]