@@ -6,6 +6,8 @@ module Data.NonEmptyList
66 where
77
88
9+import Control.Monad (liftM2)
10+import Data.Binary (Binary, get, put)
911import qualified Data.List as List
1012
1113
@@ -55,3 +57,12 @@ sortBy comparison (List x xs) =
5557 LT -> List x (y:ys)
5658 EQ -> List x (y:ys)
5759 GT -> List y (List.insertBy comparison x ys)
60+
61+
62+
63+-- BINARY
64+
65+
66+instance (Binary a) => Binary (List a) where
67+ put (List x xs) = put x >> put xs
68+ get = liftM2 List get get