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

Remove required fields from json xpiler #460

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/haskell/natural4/src/LS/XPile/ExportTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
dquotes "type" <> ": " <> dquotes (pretty t)

showRequireds :: [Field] -> Doc ann
showRequireds fds =

Check warning on line 379 in lib/haskell/natural4/src/LS/XPile/ExportTypes.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Defined but not used: ‘showRequireds’

Check warning on line 379 in lib/haskell/natural4/src/LS/XPile/ExportTypes.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Defined but not used: ‘showRequireds’

Check warning on line 379 in lib/haskell/natural4/src/LS/XPile/ExportTypes.hs

View workflow job for this annotation

GitHub Actions / build (macos-11)

Defined but not used: ‘showRequireds’

Check warning on line 379 in lib/haskell/natural4/src/LS/XPile/ExportTypes.hs

View workflow job for this annotation

GitHub Actions / build (macos-11)

Defined but not used: ‘showRequireds’

Check warning on line 379 in lib/haskell/natural4/src/LS/XPile/ExportTypes.hs

View workflow job for this annotation

GitHub Actions / build (macos-12)

Defined but not used: ‘showRequireds’

Check warning on line 379 in lib/haskell/natural4/src/LS/XPile/ExportTypes.hs

View workflow job for this annotation

GitHub Actions / build (macos-12)

Defined but not used: ‘showRequireds’
dquotes "required" <> ": " <>
brackets (hsep (punctuate comma (map (dquotes . pretty . (.fieldName)) fds)))

Expand Down Expand Up @@ -426,8 +426,9 @@
nest 4 (brackets (hsep (punctuate comma (map (dquotes . pretty) enums))))
))
showTypesJson (ExpTypeRecord tn fds) =
pprintJsonObj tn fds requiredFds
where requiredFds = "," <> nest 4 (showRequireds fds)
pprintJsonObj tn fds ""
-- ""
-- where requiredFds = "," <> nest 4 (showRequireds fds)

pprintJsonObj :: (Pretty a, ShowTypesJson b) => a -> [b] -> Doc ann -> Doc ann
pprintJsonObj key values final =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
the target language is: prolog.

the templates are:
*a some var* pred *a some var* 10,
*a number* <= *a number*,
*a date* is before *a date*,
*a date* is after *a date*,
*a date* is strictly before *a date*,
*a date* is strictly after *a date*,
*a class*'s *a field* is *a value*,
*a class*'s nested *a list of fields* is *a value*,
*a class*'s *a field0*'s *a field1* is *a value*,
*a class*'s *a field0*'s *a field1*'s *a field2* is *a value*,
*a class*'s *a field0*'s *a field1*'s *a field2*'s *a field3* is *a value*,
*a class*'s *a field0*'s *a field1*'s *a field2*'s *a field3*'s *a field4* is *a value*,
*a number* is a lower bound of *a list*,
*a number* is an upper bound of *a list*,
*a number* is the minimum of *a number* and the maximum of *a number* and *a number*,
the sum of *a list* does not exceed the minimum of *a list*,
*a number* does not exceed the minimum of *a list*.


% Predefined stdlib for translating natural4 -> LE.
the knowledge base lib includes:
a number <= an other number
if number =< other number.

% Note: LE's parsing of [H | T] is broken atm because it transforms that
% into [H, T] rather than the Prolog term [H | T].

% a class's nested [] is a value.

% a class's nested [a field | a fields] is a value
% if the class's the field is an other class
% and the other class's nested the fields is the value.

a d0 is before a d1
if d0 is a n days before d1
and n >= 0.

a d0 is strictly before a d1
if d0 is a n days before d1
and n > 0.

a d0 is after a d1
if d1 is before d0.

a d0 is strictly after a d1
if d1 is strictly before d0.

% Nested accessor predicates.
a class's a field is a value
if field is different from name
and field is different from id
and a class0's name is class
or class0's id is class
and class0's field is value.

a class's a field0's a field1 is a value
if class's field0 is a class0
and class0's field1 is value.

a class's a field0's a field1's a field2 is a value
if class's field0 is a class0
and class0's field1 is a class1
and class1's field2 is value.

a class's a field0's a field1's a field2's a field3 is a value
if class's field0 is a class0
and class0's field1 is a class1
and class1's field2 is a class2
and class2's field3 is value.

a class's a field0's a field1's a field2's a field3's a field4 is a value
if the class's field0 is a class0
and class0's field1 is a class1
and class1's field2 is a class2
and class2's field3 is a class3
and class3's field4 is value.

% Arithmetic predicates.
a number is an upper bound of a list
if for all cases in which
a X is in list
it is the case that
X is [a class, a field]
and class's field is a value
and number >= value
or number >= X.

a number is a lower bound of a list
if for all cases in which
a X is in list
it is the case that
X is [a class, a field]
and class's field is a value
and number =< value
or number =< X.

% number = min(x, max(y, z))
a number is the minimum of a x and the maximum of a y and a z
if a m is the maximum of [y, z]
and number is the minimum of [x, m].

a number does not exceed the minimum of a list of numbers
if a min is the minimum of list of numbers
and number =< min.

the sum of a list does not exceed the minimum of a other list
if a x is the sum of list
and x does not exceed the minimum of other list.

the knowledge base rules includes:
subbed by something pred a some var 10
if some var pred some var 10.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: "two conditions that are the same, except that one param in one condition got subbed by an atom / constant"
enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
the target language is: prolog.

the templates are:
*a some var* pred *a some var* 10,
*a number* <= *a number*,
*a date* is before *a date*,
*a date* is after *a date*,
*a date* is strictly before *a date*,
*a date* is strictly after *a date*,
*a class*'s *a field* is *a value*,
*a class*'s nested *a list of fields* is *a value*,
*a class*'s *a field0*'s *a field1* is *a value*,
*a class*'s *a field0*'s *a field1*'s *a field2* is *a value*,
*a class*'s *a field0*'s *a field1*'s *a field2*'s *a field3* is *a value*,
*a class*'s *a field0*'s *a field1*'s *a field2*'s *a field3*'s *a field4* is *a value*,
*a number* is a lower bound of *a list*,
*a number* is an upper bound of *a list*,
*a number* is the minimum of *a number* and the maximum of *a number* and *a number*,
the sum of *a list* does not exceed the minimum of *a list*,
*a number* does not exceed the minimum of *a list*.


% Predefined stdlib for translating natural4 -> LE.
the knowledge base lib includes:
a number <= an other number
if number =< other number.

% Note: LE's parsing of [H | T] is broken atm because it transforms that
% into [H, T] rather than the Prolog term [H | T].

% a class's nested [] is a value.

% a class's nested [a field | a fields] is a value
% if the class's the field is an other class
% and the other class's nested the fields is the value.

a d0 is before a d1
if d0 is a n days before d1
and n >= 0.

a d0 is strictly before a d1
if d0 is a n days before d1
and n > 0.

a d0 is after a d1
if d1 is before d0.

a d0 is strictly after a d1
if d1 is strictly before d0.

% Nested accessor predicates.
a class's a field is a value
if field is different from name
and field is different from id
and a class0's name is class
or class0's id is class
and class0's field is value.

a class's a field0's a field1 is a value
if class's field0 is a class0
and class0's field1 is value.

a class's a field0's a field1's a field2 is a value
if class's field0 is a class0
and class0's field1 is a class1
and class1's field2 is value.

a class's a field0's a field1's a field2's a field3 is a value
if class's field0 is a class0
and class0's field1 is a class1
and class1's field2 is a class2
and class2's field3 is value.

a class's a field0's a field1's a field2's a field3's a field4 is a value
if the class's field0 is a class0
and class0's field1 is a class1
and class1's field2 is a class2
and class2's field3 is a class3
and class3's field4 is value.

% Arithmetic predicates.
a number is an upper bound of a list
if for all cases in which
a X is in list
it is the case that
X is [a class, a field]
and class's field is a value
and number >= value
or number >= X.

a number is a lower bound of a list
if for all cases in which
a X is in list
it is the case that
X is [a class, a field]
and class's field is a value
and number =< value
or number =< X.

% number = min(x, max(y, z))
a number is the minimum of a x and the maximum of a y and a z
if a m is the maximum of [y, z]
and number is the minimum of [x, m].

a number does not exceed the minimum of a list of numbers
if a min is the minimum of list of numbers
and number =< min.

the sum of a list does not exceed the minimum of a other list
if a x is the sum of list
and x does not exceed the minimum of other list.

the knowledge base rules includes:
subbed by something pred a some var 10
if some var pred some var 10.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GIVEN,some var,
DECIDE,subbed by something,pred,some var,10,
IF,some var,pred,some var,10,
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
the target language is: prolog.

the templates are:

*a add savings* bleh 100,
*a number* <= *a number*,
*a date* is before *a date*,
*a date* is after *a date*,
Expand Down Expand Up @@ -111,5 +111,5 @@ the knowledge base lib includes:
and x does not exceed the minimum of other list.

the knowledge base rules includes:
a total savings is 100
if a add savings is 200.
a total savings bleh 100
if a add savings bleh 100.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
the target language is: prolog.

the templates are:

*a add savings* bleh 100,
*a number* <= *a number*,
*a date* is before *a date*,
*a date* is after *a date*,
Expand Down Expand Up @@ -111,5 +111,5 @@ the knowledge base lib includes:
and x does not exceed the minimum of other list.

the knowledge base rules includes:
a total savings is 100
if a add savings is 200.
a total savings bleh 100
if a add savings bleh 100.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GIVEN,total savings,IS A,Total Savings
,add savings,IS A,Add Savings
DECIDE,total savings,IS,100
IF,add savings,IS,200
DECIDE,total savings,bleh,100
IF,add savings,bleh,100
Loading