~singpolyma/dhall-ruby

ref: b561310f04f8e0b358b39679da096e1d5eb953aa dhall-ruby/lib/dhall/builtins.rb -rw-r--r-- 8.2 KiB
Update handling of builtins

Always parse to a special value and not to variables.
Encode seperately.
Test typechecker edge cases
fix type => [value|element]_type
Clean up style violations
Flatten/unfill applications and builtins when encoding
Remove multi-argument applications

They only exist in binary encoding, so let's keep them there.
Working typechecker
Binary encoding

Every AST node uses as_json to express the generic structure for
encoding itself.  Expression aliases as_cbor to as_json by default and
then uses as_cbor in to_cbor (aliased as to_binary).

This design is because we need to override the encoding of Double for
CBOR, but want to keep the normal Float value for as_json in case that
is used directly (to avoid surprising the user).
Generic subexpression_map

Make every Expression a ValueSemantics and use the known list of
attributes to map generically over any AST node.

Introduces a conditional, but removes boilerplate from every single
class.
Bare minimum refactor to pass the metrics
Pass most compliance tests

No import or multiline string support yet
Beta normalization complete
All beta normalization except for functions
Implement many builtins and do Optional section