Package

purescript-tagged-sum

Repository
lumihq/purescript-tagged-sum
License
Apache-2.0
Uploaded by
paf31
Published on
2019-05-22T22:57:26Z

A simple row-based variant data type, supporting:

  • An Aeson-compatible JSON representation, via foreign-generic
  • (Polymorphic) traversals via Prisms from profunctor-lenses

Example

$ pulp repl

> import Data.Lens (review)
> import Data.Symbol (SProxy(..))
> import Data.TaggedSum (TaggedSum, tag)
> import Foreign.Generic (encodeJSON)

> _foo = SProxy :: SProxy "foo"
> x = review (tag _foo) 42 :: TaggedSum (foo :: Int)
> encodeJSON x
"{\"tag\":\"foo\",\"contents\":42}"