Skip to content

An implementation of json-logic-js but its not out-of-the-box interoperable with other library written in other languages. Any json logic written in this library will work with others but the other way around is not true.

Notifications You must be signed in to change notification settings

nammayatri/json-logic-hs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-logic-hs

This parser accepts JsonLogic rules and executes them in Haskell

This is a Haskell porting of the excellent GitHub project by jwadhams for JavaScript: json-logic-js.

All credit goes to him, this is simply an implementation of the same logic in Haskell (small differences below).

The JsonLogic format is designed to allow you to share rules (logic) between front-end and back-end code (regardless of language difference), even to store logic along with a record in a database. JsonLogic is documented extensively at JsonLogic.com, including examples of every supported operation and a place to try out rules in your browser.

The same format can also be executed in PHP by the library json-logic-php

Examples

Simple

import JsonLogic
import Data.Aeson as A
import qualified Data.Aeson.QQ.Simple as AQ

test :: IO ()
test = do
  let tests = [AQ.aesonQQ|{ "==": [1,1]}|]
  let data_ = A.Null
  print $ jsonLogic tests data_

About

An implementation of json-logic-js but its not out-of-the-box interoperable with other library written in other languages. Any json logic written in this library will work with others but the other way around is not true.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •