2 ms·
Better yet: newtype Node a = (a, string) op :: (a -> b -> c) -> string -> node a -> Node b -> Node c op (<>) str left right = (fst left <> fst rig
by loup-vaillant 17y ago
Better yet:
newtype Node a = (a, string)
op :: (a -> b -> c) -> string -> node a -> Node b -> Node c
op (<>) str left right = (fst left <> fst right,
"(" ++ snd left ++ " " ++ str ++ " " ++ snd right ++ ")")
plus = op (+) "+"
mult = op (*) "*"
minus = op (-) "-"
constant x = (x, show x)
I don't even need eval: Haskell is non strict!