Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the expr body or function name in Response object #179

Open
jbtrystram opened this issue Mar 29, 2023 · 0 comments
Open

Add the expr body or function name in Response object #179

jbtrystram opened this issue Mar 29, 2023 · 0 comments
Assignees

Comments

@jbtrystram
Copy link
Contributor

jbtrystram commented Mar 29, 2023

Consider the following pattern: pattern can-drink = $(self > 18) .

The input 12 produce the following result :

{
  "name": {
    "pattern": "playground::can-drink"
  },
  "input": 10,
  "satisfied": false,
  "reason": "The expression defined in the pattern is not satisfied"
}

This makes it hard to debug, because when inspecting i don't really know what expression the input was checked against

Here it is pretty easy. but if you consider a slightly more complicated pattern :

pattern can-drink = $(self > 18)
pattern can-drive = $(self > 16)

pattern responsible-person = can-drink && can-drive

Giving it 17 only fails one :

{
  "name": {
    "pattern": "lang::and"
  },
  "bindings": {
    "terms": []
  },
  "input": 17,
  "satisfied": false,
  "reason": "The input does not satisfy the function",
  "rationale": [
    {
      "name": {
        "pattern": "playground::can-drink"
      },
      "bindings": {
        "terms": []
      },
      "input": 17,
      "satisfied": false,
      "reason": "The expression defined in the pattern is not satisfied"
    },
    {
      "name": {
        "pattern": "playground::can-drive"
      },
      "bindings": {
        "terms": []
      },
      "input": 17,
      "output": 17,
      "satisfied": true,
      "reason": "The expression defined in the pattern is satisfied"
    }
  ]
}

this is harder to debug, although in this case, both patterns have names so it's ok.
make it harder : pattern responsible-person = $(self > 18) && $(self > 16)

Then the result is :

{
  "name": {
    "pattern": "lang::and"
  },
  "bindings": {
    "terms": [
      {
        "Expr": {
          "GreaterThan": [
            {
              "SelfLiteral": []
            },
            {
              "Value": {
                "Integer": 18
              }
            }
          ]
        }
      },
      {
        "Expr": {
          "GreaterThan": [
            {
              "SelfLiteral": []
            },
            {
              "Value": {
                "Integer": 16
              }
            }
          ]
        }
      }
    ]
  },
  "input": 17,
  "satisfied": false,
  "reason": "The input does not satisfy the function",
  "rationale": [
    {
      "input": 17,
      "satisfied": false,
      "reason": "The expression defined in the pattern is not satisfied"
    },
    {
      "input": 17,
      "output": 17,
      "satisfied": true,
      "reason": "The expression defined in the pattern is satisfied"
    }
  ]
} 
@jbtrystram jbtrystram self-assigned this Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant