Advertisement
Guest User

Hashable instance with tuples

a guest
May 25th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. instance Hashable LeafExpr where
  2. hash (Var name) = hash ("Leaf-Var", name)
  3. hash Star = hash "Leaf-Star"
  4. hash (Const n) = hash ("Leaf-Const", n)
  5.  
  6. instance Hashable UnaryOp where
  7. hash (Neg) = hash "Unary-Neg"
  8. hash (BinNot) = hash "Unary-BinNot"
  9.  
  10. instance Hashable BinaryOp where
  11. hash (Plus) = hash "Binary-Plus"
  12. hash (Minus) = hash "Binary-Minus"
  13. hash (Times) = hash "Binary-Times"
  14. hash (Div) = hash "Binary-Div"
  15. hash (Mod) = hash "Binary-Mod"
  16.  
  17. instance Hashable NodeExpr where
  18. hash (Leaf node) = hash ("Leaf", node)
  19. hash (Unary op node) = hash ("Unary", op, node)
  20. hash (Binary op node node') = hash ("Binary", op, node, node')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement