Skip to content

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.

License

Notifications You must be signed in to change notification settings

justinwoo/purescript-bibimbap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purescript-Bibimbap

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.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published