generated from tpl/purs
fix: serializable nea
This commit is contained in:
parent
3c146ae4c6
commit
939f6d1dcd
@ -5,6 +5,7 @@ workspace:
|
||||
dependencies:
|
||||
- aff
|
||||
- aff-promise
|
||||
- arrays
|
||||
- bifunctors
|
||||
- effect
|
||||
- either
|
||||
|
@ -5,6 +5,7 @@ package:
|
||||
dependencies:
|
||||
- aff
|
||||
- aff-promise
|
||||
- arrays
|
||||
- bifunctors
|
||||
- effect
|
||||
- either
|
||||
|
@ -2,8 +2,10 @@ module Node.Worker.Serializable where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Control.Monad.Error.Class (throwError)
|
||||
import Control.Monad.Error.Class (liftMaybe, throwError)
|
||||
import Control.Monad.Except (runExcept)
|
||||
import Data.Array.NonEmpty (NonEmptyArray)
|
||||
import Data.Array.NonEmpty as Array.NonEmpty
|
||||
import Data.Bifunctor (lmap)
|
||||
import Data.Either (Either(..))
|
||||
import Data.Maybe (Maybe(..))
|
||||
@ -59,6 +61,10 @@ instance Serializable a => Serializable (Array a) where
|
||||
serialize a = unsafeToForeign a
|
||||
deserialize = flip bind (traverse deserialize) <<< lmap show <<< runExcept <<< readArray
|
||||
|
||||
instance Serializable a => Serializable (NonEmptyArray a) where
|
||||
serialize a = unsafeToForeign $ Array.NonEmpty.toArray a
|
||||
deserialize = flip bind (liftMaybe "expected non-empty array" <<< Array.NonEmpty.fromArray) <<< deserialize
|
||||
|
||||
instance Serializable a => Serializable (Object a) where
|
||||
serialize a = unsafeToForeign a
|
||||
deserialize a =
|
||||
|
Loading…
Reference in New Issue
Block a user