Commit 97e062f3 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Add an IsNode instance for Either.

Signed-off-by: default avatarEdward Z. Yang <>
parent e64f5b0b
......@@ -170,6 +170,13 @@ class Ord (Key a) => IsNode a where
nodeKey :: a -> Key a
nodeNeighbors :: a -> [Key a]
instance (IsNode a, IsNode b, Key a ~ Key b) => IsNode (Either a b) where
type Key (Either a b) = Key a
nodeKey (Left x) = nodeKey x
nodeKey (Right x) = nodeKey x
nodeNeighbors (Left x) = nodeNeighbors x
nodeNeighbors (Right x) = nodeNeighbors x
-- | A simple, trivial data type which admits an 'IsNode' instance.
data Node k a = N a k [k]
deriving (Show, Eq)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment