Skip to content

An easy way to work with Errors by inserting a Variant, and reading it out later.

License

Notifications You must be signed in to change notification settings

justinwoo/purescript-chirashi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purescript-Chirashi

Build Status

Docs on Pursuit

An easy way to work with Errors by inserting a Variant, and reading it out later.

Works by subclassing Error.

Usage

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.

Other links

For more ideas on what you could do with this library, see Ochadzuke.

About

An easy way to work with Errors by inserting a Variant, and reading it out later.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published