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

Get rid of free-floating atoms. Everything has a type now! #3671

Merged
merged 114 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
fe10db6
better parsing of type sigs
kustosz May 5, 2022
084cdab
testing facilities
kustosz May 6, 2022
2d99f1a
resolution testing
kustosz May 6, 2022
1b3457b
plug in basic resolution
kustosz May 6, 2022
aeb2b28
resolution of imported atoms
kustosz May 6, 2022
8745762
make types exportable
kustosz May 6, 2022
683cd04
use sigs in suggestion builder
kustosz May 26, 2022
2997cdc
fix union types
kustosz May 27, 2022
a0cdbe3
fix the suggestion builder to use sum types
kustosz May 27, 2022
dde6c8c
write proper level tests for unions
kustosz May 27, 2022
6a83655
fix all tests
kustosz Jun 4, 2022
37ca55d
fix docs & tests
kustosz Jun 4, 2022
d4e7650
fix formatting
kustosz Jun 4, 2022
1237536
fmt & doc
kustosz Jun 4, 2022
e7bbb26
keep moving towards actual tycons
kustosz Jun 28, 2022
675fb78
mega awesome fix
kustosz Jun 29, 2022
abe1a4a
checkpoint
kustosz Jul 13, 2022
5a6d749
checkpoint
kustosz Jul 14, 2022
e3bbaaa
checkpoint
kustosz Jul 28, 2022
9310fc7
builtin dsl changes
kustosz Jul 29, 2022
2ce6fd2
keep fighting the compiler
kustosz Jul 29, 2022
ff0f6a0
holy cow it compiled
kustosz Jul 29, 2022
29f0bd0
actually have some tests pass!
kustosz Jul 29, 2022
7c54ab8
fix dataflow analysis
kustosz Aug 3, 2022
64fbd07
testing progress
kustosz Aug 3, 2022
c7a81ee
another undeniable success
kustosz Aug 3, 2022
6d95c4a
more painstaking fixing
kustosz Aug 3, 2022
f19c994
keep going, try not to cry
kustosz Aug 3, 2022
63b61f4
more progress
kustosz Aug 3, 2022
0d23124
keep em passing
kustosz Aug 3, 2022
6e5fa16
checkpoint
kustosz Aug 4, 2022
95b097f
Merge branch 'develop' into wip/mk/parse-types
kustosz Aug 4, 2022
5f06fda
post-merge fix
kustosz Aug 4, 2022
847fffa
error refactoring
kustosz Aug 4, 2022
8ad6bf5
fix more tests
kustosz Aug 4, 2022
184b54c
make the benchmarks compile
kustosz Aug 9, 2022
2092fd6
update benchmarks
kustosz Aug 9, 2022
30d8e6e
simplify dispatch
kustosz Aug 10, 2022
e46fbc3
fix all semantic tests
kustosz Aug 10, 2022
b4f4531
start fixing stdlib
kustosz Aug 10, 2022
30ecb0a
keep going
kustosz Aug 10, 2022
5f3475b
more
kustosz Aug 10, 2022
49c1282
Keep going. Actually help myself in the compiler
kustosz Aug 11, 2022
f3b4814
more progress, same amount of suffering
kustosz Aug 11, 2022
0043065
progress
kustosz Aug 11, 2022
2faceeb
keep going
kustosz Aug 12, 2022
c8052a7
first passing test
kustosz Aug 15, 2022
d53adc9
implement getters
kustosz Aug 15, 2022
d19bf5b
fix errors
kustosz Aug 15, 2022
6d9b65e
keep going
kustosz Aug 15, 2022
72da137
keep going
kustosz Aug 16, 2022
dbecbbe
progress
kustosz Aug 16, 2022
4730eee
progress
kustosz Aug 17, 2022
ca352cd
fix all of Base
kustosz Aug 17, 2022
fefdf7e
cleanup; move on to tables
kustosz Aug 17, 2022
fde9ec4
prog
kustosz Aug 17, 2022
cfbd607
first successes in table
kustosz Aug 18, 2022
875d02d
progress
kustosz Aug 18, 2022
4889661
keep going
kustosz Aug 23, 2022
26fc60c
another test
kustosz Aug 23, 2022
010abe4
progress
kustosz Aug 23, 2022
31066d5
more passing specs
kustosz Aug 23, 2022
cc29f18
more successes
kustosz Aug 23, 2022
b9f771c
rest of db specs
kustosz Aug 25, 2022
00283d1
image tests
kustosz Aug 25, 2022
2905f31
example tests
kustosz Aug 25, 2022
feb545c
geo tests
kustosz Aug 25, 2022
a8514fa
vis tests
kustosz Aug 25, 2022
e992f0c
progress on compiler specs
kustosz Aug 25, 2022
aef3e23
more compiler tests pass
kustosz Aug 25, 2022
c662f05
test progress
kustosz Aug 25, 2022
b969fdd
fix suggestion builder
kustosz Aug 25, 2022
072abaa
keep fixing tests
kustosz Aug 25, 2022
2be4b19
fix deserializing AA metadata
kustosz Aug 26, 2022
b0d573f
last of runtime tests
kustosz Aug 26, 2022
d44d321
fix runtime instrument, progress on tests
kustosz Aug 26, 2022
678ed84
all tests pass
kustosz Aug 26, 2022
d040c77
ALL tests
kustosz Aug 26, 2022
7d205f2
Merge branch 'develop' into wip/mk/parse-types
kustosz Aug 26, 2022
21fc962
fix all of Base once again, after merge....
kustosz Aug 26, 2022
aa73059
fix all of table again...
kustosz Aug 26, 2022
214081e
Update distribution/lib/Standard/Base/0.0.0-dev/src/Data/Any.enso
kustosz Aug 27, 2022
6578c3c
Merge remote-tracking branch 'origin/develop' into wip/mk/parse-types
kustosz Aug 29, 2022
cdbfe6a
another merge
kustosz Aug 29, 2022
0852efa
try a thingy
kustosz Aug 29, 2022
c1b22d4
atomic hack
kustosz Aug 29, 2022
4d78453
case?
kustosz Aug 29, 2022
05124b5
everybody is ci-fighting
kustosz Aug 29, 2022
50df2c9
fix postgres
kustosz Aug 29, 2022
eb8c6ec
fix geo tests
kustosz Aug 29, 2022
38ffadd
more fixes
kustosz Aug 29, 2022
7b82ac4
revert hackering
kustosz Aug 29, 2022
2eeac50
Merge branch 'develop' into wip/mk/parse-types
kustosz Aug 30, 2022
40cbb70
format it
kustosz Aug 30, 2022
552166f
changelog it
kustosz Aug 30, 2022
034b74f
some CR feedback;
kustosz Aug 30, 2022
06dc4e0
Update distribution/lib/Standard/Image/0.0.0-dev/src/Codecs.enso
kustosz Aug 30, 2022
a52c828
Update distribution/lib/Standard/Image/0.0.0-dev/src/Codecs.enso
kustosz Aug 30, 2022
48c8bd9
Update test/Table_Tests/src/Data_Formatter_Spec.enso
kustosz Aug 30, 2022
8ecf7a1
Update test/Table_Tests/src/Data_Formatter_Spec.enso
kustosz Aug 30, 2022
4d9958a
Update test/Table_Tests/src/Data_Formatter_Spec.enso
kustosz Aug 30, 2022
ec17e7f
Update test/Table_Tests/src/Excel_Spec.enso
kustosz Aug 30, 2022
9cfe2b0
Update test/Tests/src/Semantic/Names_Spec.enso
kustosz Aug 30, 2022
9a84217
stuff
kustosz Aug 30, 2022
65e2582
.
kustosz Aug 30, 2022
fdf06a9
Update distribution/lib/Standard/Image/0.0.0-dev/src/Codecs.enso
kustosz Aug 30, 2022
c91dc45
Update distribution/lib/Standard/Image/0.0.0-dev/src/Codecs.enso
kustosz Aug 30, 2022
83060ef
Update test/Table_Tests/src/Excel_Spec.enso
kustosz Aug 30, 2022
3ebf4a8
Update test/Tests/src/Data/Text_Spec.enso
kustosz Aug 30, 2022
1bf52b8
continue
kustosz Aug 30, 2022
8ff4f9e
fmt
kustosz Aug 30, 2022
f733104
fix tests
kustosz Aug 30, 2022
c73fea5
fmt
kustosz Aug 30, 2022
2ee29c0
missing foc
kustosz Aug 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 10 additions & 13 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Any.enso
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ from Standard.Base import all

from Standard.Base.Error.Common import dataflow_error_handler

# The type that subsumes all types.
type Any

## Any is the universal top-type, with all other types being subsumed by it.
## Any is the universal top-type, with all other types being subsumed by it.

If a value of type Any is expected in a given location, _any value_ can
be used in that position.
@Builtin_Type
type Any
If a value of type Any is expected in a given location, _any value_ can
be used in that position.
@Builtin_Type
type Any

## PRIVATE

Expand Down Expand Up @@ -78,19 +75,19 @@ type Any
== self that = if Meta.is_same_object self that then True else
self_meta = Meta.meta self
that_meta = Meta.meta that
case Cons self_meta that_meta of
Cons (Meta.Atom _) (Meta.Atom _) ->
case Pair_Data self_meta that_meta of
Pair_Data (Meta.Atom_Data _) (Meta.Atom_Data _) ->
c_1 = self_meta.constructor
c_2 = that_meta.constructor
if Meta.is_same_object c_1 c_2 . not then False else
f_1 = self_meta.fields
f_2 = that_meta.fields
0.up_to f_1.length . all i-> (f_1.at i) == (f_2.at i)
Cons (Meta.Error _) (Meta.Error _) -> self_meta.payload == that_meta.payload
Cons (Meta.Polyglot o_1) (Meta.Polyglot o_2) ->
Pair_Data (Meta.Error_Data _) (Meta.Error_Data _) -> self_meta.payload == that_meta.payload
Pair_Data (Meta.Polyglot_Data o_1) (Meta.Polyglot_Data o_2) ->
langs_match = (self_meta.get_language == Meta.Java) && (that_meta.get_language == Meta.Java)
if langs_match.not then False else o_1.equals o_2
Cons (Meta.Unresolved_Symbol _) (Meta.Unresolved_Symbol _) ->
Pair_Data (Meta.Unresolved_Symbol_Data _) (Meta.Unresolved_Symbol_Data _) ->
(self_meta.name == that_meta.name) && (self_meta.scope == that_meta.scope)
## Constructor comparison is covered by the identity equality.
Primitive objects should define their own equality.
Expand Down
10 changes: 3 additions & 7 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import Standard.Base.Data.Vector

## Utilities for working with primitive arrays.
## The type of primitive mutable arrays.
@Builtin_Type
type Array

## The type of primitive mutable arrays.
@Builtin_Type
type Array

## Gets the element at index in the array this.

Arguments:
Expand Down Expand Up @@ -68,7 +64,7 @@ type Array
[1, 2, 3, 4].to_array.to_default_visualization_data
to_default_visualization_data : Text
to_default_visualization_data self =
Vector.Vector self . to_default_visualization_data
Vector.Vector_Data self . to_default_visualization_data

## Creates an array with length 0.

Expand Down
23 changes: 7 additions & 16 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Boolean.enso
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
## Booleans.
type Boolean

## A type with only two possible values.
## A type with only two possible values.

The boolean type represents the two truth values of boolean logic. It is
primarily used for control-flow.
@Builtin_Type
type Boolean
The boolean type represents the two truth values of boolean logic. It is
primarily used for control-flow.
@Builtin_Type
type Boolean
True
False

## Compares two booleans for equality.

Expand Down Expand Up @@ -106,11 +105,3 @@ type Boolean
if (27 % 3) == 0 then IO.println "Fizz"
if_then : Any -> Any | Nothing
if_then self ~on_true = @Builtin_Method "Boolean.if_then"

## The constructor for the value True.
@Builtin_Type
type True

## The constructor for the value False.
@Builtin_Type
type False
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ type Index_Sub_Range

Selects no items if `count` is less than or equal to 0.
Selects all items if `count` is greater than the length of the input.
type First (count : Integer = 1)
First (count : Integer = 1)

## Select the last `count` characters.

Selects no items if `count` is less than or equal to 0.
Selects all items if `count` is greater than the length of the input.
type Last (count : Integer = 1)
Last (count : Integer = 1)

## Select elements from the start while the predicate returns `True`.
type While (predicate : (Any -> Boolean))
While (predicate : (Any -> Boolean))

## Selects specific indexes (starting from 0) either as an `Integer` or a
`Range`.
Expand All @@ -28,18 +28,18 @@ type Index_Sub_Range
Only ranges with positive step and positive indices are supported.
Individual integer indices can be negative which allows for indexing
from the end of the collection.
type By_Index (indexes : (Integer | Range | Vector (Integer | Range)) = [0])
By_Index (indexes : (Integer | Range | Vector (Integer | Range)) = [0])

## Gets a random sample of entries, without repetitions.

If `count` is greater than the length of the input, a random permutation
of all elements from the input is selected.
type Sample (count:Integer) (seed:Integer=Random.get_default_seed)
Sample (count:Integer) (seed:Integer=Random.get_default_seed)

## Gets every Nth entry.

Arguments:
- step: The step between consecutive entries that are included.
- first: The first entry to include. If it is outside of bounds of the
input, an error is raised.
type Every (step:Integer) (first:Integer=0)
Every (step:Integer) (first:Integer=0)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export Standard.Base.Data.Interval.Bound

example_exclusive = Interval.exclusive 0.1 0.5
exclusive : Number -> Number -> Interval
exclusive start end = Interval (Bound.Exclusive start) (Bound.Exclusive end)
exclusive start end = Interval_Data (Bound.Exclusive start) (Bound.Exclusive end)

## Creates an interval that excludes its lower bound.

Expand All @@ -24,7 +24,7 @@ exclusive start end = Interval (Bound.Exclusive start) (Bound.Exclusive end)

example_start_exclusive = Interval.start_exclusive 1 5
start_exclusive : Number -> Number -> Interval
start_exclusive start end = Interval (Bound.Exclusive start) (Bound.Inclusive end)
start_exclusive start end = Interval_Data (Bound.Exclusive start) (Bound.Inclusive end)

## Creates an interval that excludes its upper bound.

Expand All @@ -35,7 +35,7 @@ start_exclusive start end = Interval (Bound.Exclusive start) (Bound.Inclusive en

example_end_exclusive = Interval.end_exclusive 1 5
end_exclusive : Number -> Number -> Interval
end_exclusive start end = Interval (Bound.Inclusive start) (Bound.Exclusive end)
end_exclusive start end = Interval_Data (Bound.Inclusive start) (Bound.Exclusive end)

## Creates an interval that includes both of its bounds.

Expand All @@ -46,7 +46,7 @@ end_exclusive start end = Interval (Bound.Inclusive start) (Bound.Exclusive end)

example_inclusive = Interval.inclusive 0 0
inclusive : Number -> Number -> Interval
inclusive start end = Interval (Bound.Inclusive start) (Bound.Inclusive end)
inclusive start end = Interval_Data (Bound.Inclusive start) (Bound.Inclusive end)

## A type representing an interval over real numbers.
type Interval
Expand All @@ -58,7 +58,7 @@ type Interval
Arguments:
- start: The start of the interval.
- end: The end of the interval.
type Interval (start : Number) (end : Number)
Interval_Data (start : Bound.Bound) (end : Bound.Bound)

## Checks if the interval contains `that`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Bound
import Standard.Base.Data.Interval.Bound

example_bound_inclusive = Bound.Inclusive 2
type Inclusive n
Inclusive n

## A bound that excludes the value `n`.

Expand All @@ -29,4 +29,4 @@ type Bound
import Standard.Base.Data.Interval.Bound

example_bound_exclusive = Bound.Exclusive 2.
type Exclusive n
Exclusive n
84 changes: 43 additions & 41 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ from_pairs contents =
parse : Text -> Json ! Parse_Error
parse json_text =
Panic.catch_java Any (Internal.parse_helper json_text) java_exception->
Error.throw (Parse_Error java_exception.getMessage)
Error.throw (Parse_Error_Data java_exception.getMessage)

## Represents a JSON structure.
type Json
Expand All @@ -48,34 +48,34 @@ type Json

Arguments:
- fields: The fields of the JSON object.
type Object fields
Object fields

## A representation of a JSON array.

Arguments:
- items: The items in the JSON array.
type Array items
Array items

## A representation of a JSON string.

Arguments:
- value: The text contained in the JSON string.
type String value
String value

## A representation of a JSON number.

Arguments:
- value: The number contained in the JSON number.
type Number value
Number value

## A representation of a JSON boolean.

Arguments:
- value: The boolean contained in a JSON boolean.
type Boolean value
Boolean value

## A representation of a JSON null.
type Null
Null

## Marshalls this JSON into an arbitrary value described by
`type_descriptor`.
Expand Down Expand Up @@ -133,19 +133,39 @@ type Json
example_unwrap = Json.Number 3 . unwrap
unwrap : Any
unwrap self = case self of
Json.Array its -> its.map .unwrap
Json.Boolean b -> b
Json.Number n -> n
Json.String t -> t
Json.Null -> Nothing
Json.Object f -> f.map .unwrap
Array its -> its.map .unwrap
Boolean b -> b
Number n -> n
String t -> t
Null -> Nothing
Object f -> f.map .unwrap

## Gets the value associated with the given key in this object.

Arguments:
- field: The name of the field from which to get the value.

Throws `Nothing` if the associated key is not defined.

> Example
Get the "title" field from this JSON representing a book.

import Standard.Base.Data.Json
import Standard.Examples

example_get = Examples.json_object.get "title"
get : Text -> Json ! No_Such_Field_Error
get self field = self.fields.get field . map_error case _ of
Map.No_Value_For_Key_Error_Data _ -> No_Such_Field_Error_Data field
x -> x
kustosz marked this conversation as resolved.
Show resolved Hide resolved

## UNSTABLE

A failure indicating malformed text input into the JSON parser.

Check the `message` field for detailed information on the specific failure.
type Parse_Error message
type Parse_Error
Parse_Error_Data message

## UNSTABLE

Expand All @@ -154,29 +174,11 @@ Parse_Error.to_display_text : Text
Parse_Error.to_display_text self =
"Parse error in parsing JSON: " + self.message.to_text + "."

## Gets the value associated with the given key in this object.

Arguments:
- field: The name of the field from which to get the value.

Throws `Nothing` if the associated key is not defined.

> Example
Get the "title" field from this JSON representing a book.

import Standard.Base.Data.Json
import Standard.Examples

example_get = Examples.json_object.get "title"
Object.get : Text -> Json ! No_Such_Field_Error
Object.get self field = self.fields.get field . map_error case _ of
Map.No_Value_For_Key_Error _ -> No_Such_Field_Error field
x -> x

## UNSTABLE

An error indicating that there is no such field in the JSON object.
type No_Such_Field_Error field_name
type No_Such_Field_Error
No_Such_Field_Error_Data field_name

## UNSTABLE

Expand All @@ -201,7 +203,7 @@ type Marshalling_Error
- format: The type format that did not match.

This can occur e.g. when trying to reinterpret a number as a `Text`, etc.
type Type_Mismatch_Error json format
Type_Mismatch_Error json format

## UNSTABLE

Expand All @@ -215,7 +217,7 @@ type Marshalling_Error

This can occure when trying to reinterpret a JSON object into an atom,
when the JSON does not contain all the fields required by the atom.
type Missing_Field_Error json field format
Missing_Field_Error json field format

## UNSTABLE

Expand Down Expand Up @@ -243,21 +245,21 @@ type Marshalling_Error
Any.to_json self =
m = Meta.meta self
case m of
Meta.Atom _ ->
cons = Meta.Constructor m.constructor
Meta.Atom_Data _ ->
cons = Meta.Constructor_Data m.constructor
fs = m.fields
fnames = cons.fields
json_fs = 0.up_to fnames.length . fold Map.empty m-> i->
m.insert (fnames.at i) (fs.at i . to_json)
with_tp = json_fs . insert "type" (String cons.name)
Object with_tp
Meta.Constructor _ ->
Meta.Constructor_Data _ ->
Object (Map.empty . insert "type" (String m.name))

## The following two cases cannot be handled generically and should
instead define their own `to_json` implementations.
Meta.Polyglot _ -> Null
Meta.Primitive _ -> Null
Meta.Polyglot_Data _ -> Null
Meta.Primitive_Data _ -> Null

## Method used by object builders to convert a value into a valid JSON key.

Expand Down
Loading