{"id":15010939,"url":"https://github.com/katydid/katydid-haskell","last_synced_at":"2025-04-09T18:40:27.949Z","repository":{"id":56845057,"uuid":"77739839","full_name":"katydid/katydid-haskell","owner":"katydid","description":"An Encoding Agnostic Validation Language","archived":false,"fork":false,"pushed_at":"2018-10-14T17:33:28.000Z","size":1365,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T20:37:20.442Z","etag":null,"topics":["automata","haskell","nested-structures","schema","validation"],"latest_commit_sha":null,"homepage":"https://katydid.github.io/katydid-haskell/","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/katydid.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-31T12:42:30.000Z","updated_at":"2023-10-23T02:25:12.000Z","dependencies_parsed_at":"2022-09-17T11:02:18.717Z","dependency_job_id":null,"html_url":"https://github.com/katydid/katydid-haskell","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katydid%2Fkatydid-haskell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katydid%2Fkatydid-haskell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katydid%2Fkatydid-haskell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katydid%2Fkatydid-haskell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katydid","download_url":"https://codeload.github.com/katydid/katydid-haskell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248089686,"owners_count":21045949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automata","haskell","nested-structures","schema","validation"],"created_at":"2024-09-24T19:37:39.771Z","updated_at":"2025-04-09T18:40:27.927Z","avatar_url":"https://github.com/katydid.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Katydid\n\n[![Build Status](https://travis-ci.org/katydid/katydid-haskell.svg?branch=master)](https://travis-ci.org/katydid/katydid-haskell)\n\nA Haskell implementation of Katydid.\n\n![Katydid Logo](https://cdn.rawgit.com/katydid/katydid.github.io/master/logo.png)\n\nThis includes:\n\n  - [Relapse](https://katydid.github.io/katydid-haskell/Relapse.html): Validation Language \n  - Parsers: [JSON](https://katydid.github.io/katydid-haskell/Json.html) and [XML](https://katydid.github.io/katydid-haskell/Xml.html)\n\n[Documentation for katydid](http://katydid.github.io/)\n\n[Documentation for katydid-haskell](https://katydid.github.io/katydid-haskell/)\n\n[Documentation for katydid-haskell/Relapse](https://katydid.github.io/katydid-haskell/Relapse.html)\n\nAll JSON and XML tests from [the language agnostic test suite](https://github.com/katydid/testsuite) [passes].\n\n[Hackage](https://hackage.haskell.org/package/katydid)\n\n## Example\n\nValidating a single structure can be done using the validate function:\n```haskell\nvalidate :: Tree t =\u003e Grammar -\u003e [t] -\u003e Bool\n```\n\n, where a tree is a class in the [Parsers](https://katydid.github.io/katydid-haskell/Parsers.html) module:\n```haskell\nclass Tree a where\n    getLabel :: a -\u003e Label\n    getChildren :: a -\u003e [a]\n```\n\nHere is an example that validates a single JSON tree:\n```haskell\nmain = either \n    (\\err -\u003e putStrLn $ \"error:\" ++ err) \n    (\\valid -\u003e if valid \n        then putStrLn \"dragons exist\" \n        else putStrLn \"dragons are fictional\"\n    ) $\n    Relapse.validate \u003c$\u003e \n        Relapse.parse \".DragonsExist == true\" \u003c*\u003e \n        Json.decodeJSON \"{\\\"DragonsExist\\\": false}\"\n```\n\n## Efficiency\n\nIf you want to validate multiple trees using the same grammar then the filter function does some internal memoization, which makes a huge difference.\n\n```haskell\nfilter :: Tree t =\u003e Grammar -\u003e [[t]] -\u003e [[t]]\n```\n\n## User Defined Functions\n\nIf you want to create your own extra functions for operating on the leaves,\nthen you can inject them into the parse function:\n\n```haskell\nmain = either\n    (\\err -\u003e putStrLn $ \"error:\" ++ err)\n    (\\valid -\u003e if valid\n        then putStrLn \"prime birthday !!!\"\n        else putStrLn \"JOMO\"\n    ) $\n    Relapse.validate \u003c$\u003e\n        Relapse.parseWithUDFs userLib \".Survived-\u003eisPrime($int)\" \u003c*\u003e\n        Json.decodeJSON \"{\\\"Survived\\\": 104743}\"\n```\n\nDefining your own user library to inject is easy.\nThe `Expr` library provides many useful helper functions:\n\n```haskell\nimport Data.Numbers.Primes (isPrime)\nimport Data.Katydid.Relapse.Expr\n\nuserLib :: String -\u003e [AnyExpr] -\u003e Either String AnyExpr\nuserLib \"isPrime\" args = mkIsPrime args\nuserLib n _ = throwError $ \"undefined function: \" ++ n\n\nmkIsPrime :: [AnyExpr] -\u003e Either String AnyExpr\nmkIsPrime args = do {\n    arg \u003c- assertArgs1 \"isPrime\" args;\n    mkBoolExpr . isPrimeExpr \u003c$\u003e assertInt arg;\n}\n\nisPrimeExpr :: Integral a =\u003e Expr a -\u003e Expr Bool\nisPrimeExpr numExpr = trimBool Expr {\n    desc = mkDesc \"isPrime\" [desc numExpr]\n    , eval = \\fieldValue -\u003e isPrime \u003c$\u003e eval numExpr fieldValue\n}\n```\n\n## Roadmap\n\n  - Protobuf parser\n  - Profile and Optimize (bring up to par with Go version)\n  - Typed DSL (Combinator)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatydid%2Fkatydid-haskell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatydid%2Fkatydid-haskell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatydid%2Fkatydid-haskell/lists"}