self(auto)- documenting encoders and decoders
Go to file
Tom Sydney Kerckhove 72033e001b
Merge pull request #28 from a5ob7r/fix_typo
Fix a typo in README
2023-05-31 09:06:48 +02:00
.github Nix flake 2022-11-30 14:33:11 +01:00
autodocodec HasCodec Void 2023-01-31 14:12:13 +01:00
autodocodec-api-usage HasCodec Void 2023-01-31 14:12:13 +01:00
autodocodec-openapi3 Nix flake 2022-11-30 14:33:11 +01:00
autodocodec-schema Bumped and released autodocodec-schema 2023-01-18 17:51:13 +01:00
autodocodec-servant-multipart Nix flake 2022-11-30 14:33:11 +01:00
autodocodec-swagger2 Nix flake 2022-11-30 14:33:11 +01:00
autodocodec-yaml Released autodocodec-yaml-0.2.0.3 2023-01-01 21:30:59 +01:00
nix reenable builds for nixos-21.11 2023-03-11 16:21:07 +01:00
.envrc Nix flake 2022-11-30 14:33:11 +01:00
.gitignore Nix flake 2022-11-30 14:33:11 +01:00
.hlint.yaml autodocodec-servant-multipart 2022-09-20 00:59:49 +02:00
cabal.project Nix flake 2022-11-30 14:33:11 +01:00
flake.lock reenable builds for nixos-21.11 2023-03-11 16:21:07 +01:00
flake.nix reenable builds for nixos-21.11 2023-03-11 16:21:07 +01:00
LICENSE Released autodocodec-yaml-0.2.0.3 2023-01-01 21:30:59 +01:00
README.md Fix a typo in README 2022-11-08 16:24:31 +09:00
stack.yaml Upgrade deps again 2023-02-13 09:08:39 +01:00
TODO.smos autodocodec-nix todo 2022-09-20 00:42:10 +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: