Skip to content
Snippets Groups Projects
Commit b9101c8d authored by Alec Theriault's avatar Alec Theriault
Browse files

'Binary (NonEmpty a)' should 'fail' on empty lists

The failure should be in the context of 'MonadFail'.
parent 1cd855a6
No related branches found
No related tags found
No related merge requests found
...@@ -830,7 +830,11 @@ instance (Binary a, Binary b) => Binary (Semigroup.Arg a b) where ...@@ -830,7 +830,11 @@ instance (Binary a, Binary b) => Binary (Semigroup.Arg a b) where
-- | /Since: 0.8.4.0/ -- | /Since: 0.8.4.0/
instance Binary a => Binary (NE.NonEmpty a) where instance Binary a => Binary (NE.NonEmpty a) where
get = fmap NE.fromList get get = do
list <- get
case list of
[] -> fail "NonEmpty is actually empty!"
x:xs -> pure (x NE.:| xs)
put = put . NE.toList put = put . NE.toList
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment