@@ -12,6 +12,7 @@ as SML/NJ to get nice trees.
14import Control.Arrow (second)
14import Control.Arrow (second)
15import qualified Data.List as List
16import qualified Data.List as List
16import qualified Data.Map as Map
17import qualified Data.Map as Map
17import qualified Data.Set as Set
18import qualified Data.Set as Set
@@ -491,3 +492,49 @@ smallBranchingFactor variantDict branches path =
491 gatherEdges variantDict branches path
492 gatherEdges variantDict branches path
493 length edges + (if null fallback then 0 else 1)
494 length edges + (if null fallback then 0 else 1)
501+instance Binary Test where
505+ 0 -> Constructor <$> get
506+ 1 -> Literal <$> get
507+ _ -> error "problem getting DecisionTree.Test binary"
512+ putWord8 0 >> put var
515+ putWord8 1 >> put literal
518+instance Binary Path where
522+ 0 -> Position <$> get <*> get
523+ 1 -> Field <$> get <*> get
526+ _ -> error "problem getting DecisionTree.Path binary"
530+ Position index rest ->
531+ putWord8 0 >> put index >> put rest
534+ putWord8 1 >> put field >> put rest