Commits

Alex Suraci committed 5ccfa84

define on a simplified trait, with only the head of a union

  • Participants
  • Parent commits 4dc1068

Comments (0)

Files changed (1)

File src/Atomy/Runtime.hs

 target :: Message Pattern -> VM Trait
 target m = do
     is <- gets primitives
-    targets' is m
+    liftM simplify (targets' is m)
   where
     targets' is (Single _ _ p) = targets'' is p
     targets' is (Keyword _ _ ps) = do
         ts <- mapM (targets'' is) ps
         return (foldr1 Intersection ts)
 
+    simplify (Unary a) = Unary a
+    simplify (Union a _) = a
+    simplify (Union a b) = Union (simplify a) (simplify b)
+    simplify (Intersection a b) = Intersection (simplify a) (simplify b)
+
     targets'' :: IDs -> Pattern -> VM Trait
     targets'' _ (PMatch v) = traitFor v
     targets'' is (PNamed _ p) = targets'' is p