Skip to content

Commit

Permalink
Better order for the parameters of the Array type.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed May 15, 2024
1 parent 927d217 commit 2a7e9f0
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 692 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
["<>" projection]]
[data
[collection
["[0]" array]
["[0]" dictionary]
["[0]" list (.use "[1]#[0]" monoid)
["?[1]" \\projection]]]]
["[0]" type (.only)
["[0]" check]]
[compiler
["@[0]" type]]
["[0]" meta (.only)
["[0]" code
["<[1]>" \\projection]]]
Expand All @@ -30,108 +31,6 @@
["[0]" analysis (.only Operation Phase Handler Bundle)
["[1]/[0]" type]]]]])

(the array::new
(-> Text Handler)
(custom
[?list.any
(function (_ extension phase archive lengthC)
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[lengthA (analysis/type.expecting Natural
(phase archive lengthC))
_ (analysis/type.inference (type (array.Array' :read: :write:)))
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list lengthA)}]))))]))

(the array::length
(-> Text Handler)
(custom
[?list.any
(function (_ extension phase archive arrayC)
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference Natural)
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list arrayA)}]))))]))

(the array::read
(-> Text Handler)
(custom
[(<>.and ?list.any ?list.any)
(function (_ extension phase archive [indexC arrayC])
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[indexA (analysis/type.expecting Natural
(phase archive indexC))
arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference :read:)
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list indexA arrayA)}]))))]))

(the array::write
(-> Text Handler)
(custom
[(all <>.and ?list.any ?list.any ?list.any)
(function (_ extension phase archive [indexC valueC arrayC])
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[indexA (analysis/type.expecting Natural
(phase archive indexC))
valueA (analysis/type.expecting :write:
(phase archive valueC))
arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference (type (array.Array' :read: :write:)))
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list indexA valueA arrayA)}]))))]))

(the array::delete
(-> Text Handler)
(custom
[(all <>.and ?list.any ?list.any)
(function (_ extension phase archive [indexC arrayC])
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[indexA (analysis/type.expecting Natural
(phase archive indexC))
arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference (type (array.Array' :read: :write:)))
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list indexA arrayA)}]))))]))

(the with_array_extensions
(-> Bundle Bundle)
(|>> (/.with "js_array_new#" array::new)
(/.with "js_array_length#" array::length)
(/.with "js_array_read#" array::read)
(/.with "js_array_write#" array::write)
(/.with "js_array_delete#" array::delete)
))

(the object::new
(-> Text Handler)
(custom
Expand Down Expand Up @@ -249,7 +148,6 @@
(the .public bundle
Bundle
(|> extension.empty
with_array_extensions
with_object_extensions

(/.with "js_constant#" js::constant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
["[0]" list (.use "[1]#[0]" mix monad monoid)
["?[1]" \\projection]]
["[0]" stack (.use "[1]#[0]" mix monad monoid)]
["[0]" array]
["[0]" dictionary (.only Dictionary)]
["[0]" sequence]]]
[math
Expand Down Expand Up @@ -508,15 +507,15 @@
(..custom
[?list.any
(function (_ extension_name analyse archive [arrayC])
(<| typeA.with_var (function (_ [@read :read:]))
typeA.with_var (function (_ [@write :write:]))
(<| typeA.with_var (function (_ [_ to_write]))
typeA.with_var (function (_ [_ to_read]))
(do phase.monad
[_ (typeA.inference ..int)
arrayA (<| (typeA.expecting (.type (array.Array' :read: :write:)))
arrayA (<| (typeA.expecting (@type.Array to_write to_read))
(analyse archive arrayC))
:read: (typeA.check (check.clean (list) :read:))
:write: (typeA.check (check.clean (list) :write:))
arrayJT (jvm_array_type (.type (array.Array' :read: :write:)))
to_read (typeA.check (check.clean (list) to_read))
to_write (typeA.check (check.clean (list) to_write))
arrayJT (jvm_array_type (@type.Array to_write to_read))
@ meta.provenance]
(in [@ {analysis.#Extension [.prelude (text extension_name "|translation")]
(list (analysis.text @ (..signature arrayJT))
Expand Down Expand Up @@ -738,17 +737,17 @@
(..custom
[(<>.and ?list.any ?list.any)
(function (_ extension_name analyse archive [idxC arrayC])
(<| typeA.with_var (function (_ [@read :read:]))
typeA.with_var (function (_ [@write :write:]))
(<| typeA.with_var (function (_ [_ to_write]))
typeA.with_var (function (_ [_ to_read]))
(do phase.monad
[_ (typeA.inference :read:)
arrayA (<| (typeA.expecting (.type (array.Array' :read: :write:)))
[_ (typeA.inference to_read)
arrayA (<| (typeA.expecting (@type.Array to_write to_read))
(analyse archive arrayC))
idxA (<| (typeA.expecting ..int)
(analyse archive idxC))
:read: (typeA.check (check.clean (list) :read:))
:write: (typeA.check (check.clean (list) :write:))
arrayJT (jvm_array_type (.type (array.Array' :read: :write:)))
to_read (typeA.check (check.clean (list) to_read))
to_write (typeA.check (check.clean (list) to_write))
arrayJT (jvm_array_type (@type.Array to_write to_read))
@ meta.provenance]
(in [@ {analysis.#Extension [.prelude (text extension_name "|translation")]
(list (analysis.text @ (..signature arrayJT))
Expand Down Expand Up @@ -782,19 +781,19 @@
(..custom
[(all <>.and ?list.any ?list.any ?list.any)
(function (_ extension_name analyse archive [idxC valueC arrayC])
(<| typeA.with_var (function (_ [@read :read:]))
typeA.with_var (function (_ [@write :write:]))
(<| typeA.with_var (function (_ [_ to_write]))
typeA.with_var (function (_ [_ to_read]))
(do phase.monad
[_ (typeA.inference (.type (array.Array' :read: :write:)))
arrayA (<| (typeA.expecting (.type (array.Array' :read: :write:)))
[_ (typeA.inference (@type.Array to_write to_read))
arrayA (<| (typeA.expecting (@type.Array to_write to_read))
(analyse archive arrayC))
idxA (<| (typeA.expecting ..int)
(analyse archive idxC))
valueA (<| (typeA.expecting :write:)
valueA (<| (typeA.expecting to_write)
(analyse archive valueC))
:read: (typeA.check (check.clean (list) :read:))
:write: (typeA.check (check.clean (list) :write:))
arrayJT (jvm_array_type (.type (array.Array' :read: :write:)))
to_read (typeA.check (check.clean (list) to_read))
to_write (typeA.check (check.clean (list) to_write))
arrayJT (jvm_array_type (@type.Array to_write to_read))
@ meta.provenance]
(in [@ {analysis.#Extension [.prelude (text extension_name "|translation")]
(list (analysis.text @ (..signature arrayJT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,108 +44,6 @@
(for .lua ffi.Function
Any))

(the array::new
(-> Text Handler)
(custom
[?list.any
(function (_ extension phase archive lengthC)
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[lengthA (analysis/type.expecting Natural
(phase archive lengthC))
_ (analysis/type.inference (type (array.Array' :read: :write:)))
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list lengthA)}]))))]))

(the array::length
(-> Text Handler)
(custom
[?list.any
(function (_ extension phase archive arrayC)
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference Natural)
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list arrayA)}]))))]))

(the array::read
(-> Text Handler)
(custom
[(<>.and ?list.any ?list.any)
(function (_ extension phase archive [indexC arrayC])
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[indexA (analysis/type.expecting Natural
(phase archive indexC))
arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference :read:)
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list indexA arrayA)}]))))]))

(the array::write
(-> Text Handler)
(custom
[(all <>.and ?list.any ?list.any ?list.any)
(function (_ extension phase archive [indexC valueC arrayC])
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[indexA (analysis/type.expecting Natural
(phase archive indexC))
valueA (analysis/type.expecting :write:
(phase archive valueC))
arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference (type (array.Array' :read: :write:)))
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list indexA valueA arrayA)}]))))]))

(the array::delete
(-> Text Handler)
(custom
[(all <>.and ?list.any ?list.any)
(function (_ extension phase archive [indexC arrayC])
(<| analysis/type.with_var
(function (_ [@read :read:]))
analysis/type.with_var
(function (_ [@write :write:]))
(do phase.monad
[indexA (analysis/type.expecting Natural
(phase archive indexC))
arrayA (analysis/type.expecting (type (array.Array' :read: :write:))
(phase archive arrayC))
_ (analysis/type.inference (type (array.Array' :read: :write:)))
@ meta.provenance]
(in [@ {analysis.#Extension (/.translation extension)
(list indexA arrayA)}]))))]))

(the with_array_extensions
(-> Bundle Bundle)
(|>> (/.with "lua_array_new#" array::new)
(/.with "lua_array_length#" array::length)
(/.with "lua_array_read#" array::read)
(/.with "lua_array_write#" array::write)
(/.with "lua_array_delete#" array::delete)
))

(the object::get
(-> Text Handler)
(custom
Expand Down Expand Up @@ -279,7 +177,6 @@
(the .public bundle
Bundle
(|> extension.empty
with_array_extensions
with_object_extensions
with_utf8_extensions

Expand Down

0 comments on commit 2a7e9f0

Please sign in to comment.