An easy way to work with Error
s by inserting a Variant
, and reading it out later.
Works by subclassing Error.
type ErrorVariant = Variant
( apple :: String
, banana :: { info :: String }
, cherry :: Unit
)
main = do
let
knownVariant :: ErrorVariant
knownVariant = Variant.inj (SProxy :: SProxy "banana") { info: "hello" }
knownError = Chirashi.mkVariantError knownVariant
resultKnownError = Chirashi.readVariant knownError
Assert.assertEqual
{ expected: Just knownVariant
, actual: resultKnownError
}
See tests for more examples.
For more ideas on what you could do with this library, see Ochadzuke.