on master help sign in
fromByteString returns maybe
aa67810aslatter
Data/UUID/Internal.hs+5−5
@@ -229,11 +229,11 @@ instance Binary Node where
229 return $ Node w1 w2 w3 w4 w5 w6
229 return $ Node w1 w2 w3 w4 w5 w6
230
230
231
231
232−-- |Extract a UUID from a 'ByteString'.
232+-- |Extract a UUID from a 'ByteString' in network byte order.
233−-- The argument must be 16 bytes long, otherwise 'nil' is returned.
233+-- The argument must be 16 bytes long, otherwise 'Nothing' is returned.
234−fromByteString :: Lazy.ByteString -> UUID
234+fromByteString :: Lazy.ByteString -> Maybe UUID
235−fromByteString bs | Lazy.length bs == 16 = decode bs
235+fromByteString bs | Lazy.length bs == 16 = Just $ decode bs
236− | otherwise = nil
236+ | otherwise = Nothing
237
237
238-- |Encode a UUID into a 'ByteString' in network order.
238-- |Encode a UUID into a 'ByteString' in network order.
239toByteString :: UUID -> Lazy.ByteString
239toByteString :: UUID -> Lazy.ByteString