BSD-3-Clause licensed by Walter Schulze
Maintained by [email protected]
This version can be pinned in stack with:katydid-0.1.1.0@sha256:ba30b8eed3449e5955265d93be9a1d9b719fdc648d5e07d3ff0b768f3e0b26aa,2698
Used by 1 package in lts-10.4(full list with versions):

Katydid

Build Status

A Haskell implementation of Katydid.

This includes:

Documentation for katydid

Documentation for katydid-haskell

Documentation for katydid-haskell/Relapse

All JSON and XML tests from the language agnostic test suite [passes].

Hackage.

Example

Validating a single structure can be done using the validate function:

validate :: Tree t => Refs -> [t] -> Bool

, where a tree is a class in the Parsers module:

class Tree a where
    getLabel :: a -> Label
    getChildren :: a -> [a]

Here is an example that validates a single JSON tree:

main = either 
    (\err -> putStrLn $ "error:" ++ err) 
    (\valid -> if valid 
        then putStrLn "dragons exist" 
        else putStrLn "dragons are fictional"
    ) $
    Relapse.validate <$> 
        runExcept (Relapse.parseGrammar ".DragonsExist == true") <*> 
        Json.decodeJSON "{\"DragonsExist\": false}"

Efficiency

If you want to validate multiple trees using the same grammar then the filter function does some internal memoization, which makes a huge difference.

filter :: Tree t => Refs -> [[t]] -> [[t]]