self(auto)- documenting encoders and decoders
Go to file
Tom Sydney Kerckhove 176a4eced3 don't double-add Wall
2022-06-28 14:13:45 +02:00
.github upgrade ci 2021-11-06 12:47:58 +01:00
autodocodec fixed doctests 2022-06-24 17:54:19 +02:00
autodocodec-api-usage build with more warnings on ci 2022-06-28 13:52:54 +02:00
autodocodec-openapi3 release autodocodec-openapi3 2022-06-19 20:33:41 +02:00
autodocodec-schema releases 2022-04-26 22:33:32 +02:00
autodocodec-swagger2 Support disjoint unions 2021-12-23 15:12:30 +01:00
autodocodec-yaml releases 2022-04-26 22:33:32 +02:00
nix don't double-add Wall 2022-06-28 14:13:45 +02:00
.gitignore trying a thing 2021-10-20 17:59:50 +02:00
.hlint.yaml Support multi-line default values in yaml schemas, fixes #8 2021-12-28 12:29:29 +01:00
ci.nix build with more warnings on ci 2022-06-28 13:52:54 +02:00
default.nix Trying to set up CI 2021-10-24 19:21:59 +02:00
LICENSE license in root dir too 2021-11-19 23:05:14 +01:00
README.md remove benchmarks that can't run 2021-11-17 14:39:36 +01:00
shell.nix build with more warnings on ci 2022-06-28 13:52:54 +02:00
stack.yaml Extra GHC flags on CI, and do not error on deprecations 2022-06-28 13:38:52 +02:00
TODO.smos Generalised the type of parseAlternative 2022-05-03 23:28:43 +02:00

Autodocodec

Autodocodec is short for "self(auto)- documenting encoder and decoder".

In short: You write a single instance, of the 'Codec' type-class, for your type, and you get:

See the golden test directory directory for example outputs.

Features

  • ✓ Correct-by-construction encoding and decoding, without generating code.
  • ✓ Generate automatically-correct documentation from code.
  • ✓ Support for recursive types.

State of this project

This project is ready to try out!

data Example = Example
  { exampleTextField :: !Text,
    exampleIntField :: !Int
  }
  deriving stock (Show, Eq, Generic)
  deriving
    ( FromJSON, -- <- FromJSON instance for free.
      ToJSON, -- <- ToJSON instance for free.
      Swagger.ToSchema, -- <- Swagger schema for free.
      OpenAPI.ToSchema -- <- OpenAPI schema for free.
    )
    via (Autodocodec Example)

instance HasCodec Example where
  codec =
    object "Example" $
      Example
        <$> requiredField "text" "documentation for the text field" .= exampleTextField
        <*> requiredField "int" "documentation for the int field" .= exampleIntField

Tests

While we don't provide any actual guarantees, we do have tests for the following properties that we would like to maintain: