Package

purescript-bibimbap

Repository
justinwoo/purescript-bibimbap
License
MIT
Uploaded by
justinwoo
Published on
2018-09-30T07:52:50Z

Build Status

Docs on Pursuit

The flip side of Chirashi, simply storing sum type values and retrieving them by using the constructor name as a test value, by using Generic.Rep to get constructor names from a sum type definition.

Works by subclassing Error.

Usage

data ErrorGenericSum
  = Apple
  | Banana { info :: String }
  | Cherry Int Int Int
derive instance genericErrorGenericSum :: GR.Generic ErrorGenericSum _

main = do
  let
    knownGenericSum :: ErrorGenericSum
    knownGenericSum = Banana { info: "hello" }
    knownError = Bibimbap.mkGenericSumError knownGenericSum
    resultKnownError = Bibimbap.readGenericSum knownError

  Assert.assertEqual
    { expected: Just knownGenericSum
    , actual: resultKnownError
    }

See tests for more examples.