3BTFGIU5ONHANVU6H522GTBJBHVDBUCC7LMI6EBZSTAKXVLS6RYAC
XSLIBX4TIHUA4SS5IJMKJ6R575FNLYGF3VIWOGCTYDNPIKZG6QFAC
J7LSWCNFU3UWTUXFHQLIRLW2BHXJA54AT6SR5JY6JK3XABO4ZIXQC
7P3WY2CHMA5QFOYGENWGIIYXDIHOUFWIIBACUPQ7KKSOWILGW3HAC
OQ24A5VRN3IFOFFO2TWLF6OOP4I5V2NSUURZXUWEFLURQP4GPP5AC
O35UMQTSQPBNLYTXGBZOVCRNDQTCG2KDF2SJNRFJSZT5J2LJJ5OAC
B2JWXIEPCMVVITDJDR2SACY4VHITXGH7ZM6A5RWN6E7OKTO43TUAC
instance FromJSON a => FromJSON (NonEmptyList a) where
parseJSON = withArray "NonEmptyList" $ \array ->
maybe (fail "Unable to parse values") pure (parseValues array)
where
parseVec = sequence . Vector.toList . Vector.map fromJSON
parseValues array = Vector.uncons array >>=
\(head, tail) -> case (fromJSON head, parseVec tail) of
(Success x, Success xs) -> pure $ NonEmptyList x xs
_ -> fail "Unable to parse values"