Stabel

Check-in [421178a365]
Login
Overview
Comment:Add array module, which I forgot in previous commit. Also change maybe type to not have a generic member. That design needs tweeking.
Timelines: family | ancestors | descendants | both | builtin-rewrite
Files: files | file ages | folders
SHA3-256: 421178a365b568d27e31792ffb368412b9c78109a8251230947f88bb606aed9f
User & Date: robin.hansen on 2021-10-08 09:36:20
Other Links: branch diff | manifest | tags
Context
2021-10-08
17:25
Fixed issue in package loader where modules wouldnt necessary parse in the correct order. check-in: 7bcedf4cb6 user: robin.hansen tags: builtin-rewrite
09:36
Add array module, which I forgot in previous commit. Also change maybe type to not have a generic me... check-in: 421178a365 user: robin.hansen tags: builtin-rewrite
2021-10-07
17:34
Fixed several new tests by adding an array module to the standard_library. check-in: b5b13855e1 user: robin.hansen tags: builtin-rewrite
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added stdlib/src/array.stbl version [4d63652b3d].



































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
defmodule:
exposing: 
  length
  push
  get
  set
:

def: length
type: (Array a) -- Int
: //stabel/hidden/array/length

def: push
type: (Array a) a -- (Array a)
: //stabel/hidden/array/push

def: get
type: (Array a) Int -- (maybe/Maybe a)
: //stabel/hidden/array/get 
  get-helper

defmulti: get-helper
type: Int a -- (maybe/Maybe a)
: 0
  core/drop core/drop
  maybe/Nothing>
: Int
  core/swap core/drop
  maybe/>Just

def: set
type: (Array a) a Int -- (Array a)
: //stabel/hidden/array/set

Modified stdlib/src/maybe.stbl from [0d0fb7d9a8] to [ad7877f523].

1
2
3




4
5
6
7
8
9
10
11
12



13
14
15
16
17
18



19

20
21
22
23
24
25
26

27
28

29
defmodule:
exposing:
  Maybe




  Nothing
  Nothing>
  map
  when-nothing
:

defunion: Maybe a
: a
: Nothing




defstruct: Nothing

defmulti: map
type: (Maybe a) [ a -- b ] -- (Maybe b)
: a



  core/!

: Nothing
  core/drop

defmulti: when-nothing
type: (Maybe a) a -- a
: a
  core/drop

: Nothing
  core/swap core/drop





>
>
>
>







|

>
>
>





|
>
>
>

>





|

>

|
>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
defmodule:
exposing:
  Maybe
  Just
  >Just
  >value
  value>
  Nothing
  Nothing>
  map
  when-nothing
:

defunion: Maybe a
: Just a
: Nothing

defstruct: Just a
: value a

defstruct: Nothing

defmulti: map
type: (Maybe a) [ a -- b ] -- (Maybe b)
: Just 
  core/swap
  value>
  core/swap
  core/!
  >Just
: Nothing
  core/drop

defmulti: when-nothing
type: (Maybe a) a -- a
: Just
  core/drop
  value>
: Nothing
  core/swap 
  core/drop

Modified wasm_tests/pattern_match.test.js from [edf563dadb] to [f2b12df315].

10
11
12
13
14
15
16


17
18
19
20
21
22
23
          drop 1
        : Box
          drop 0

        def: main
        : 0 >Box box-not
    `);



    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(1);
});

test('Basic pattern match with default implementation', async () => {







>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
          drop 1
        : Box
          drop 0

        def: main
        : 0 >Box box-not
    `);

    console.log(wat);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(1);
});

test('Basic pattern match with default implementation', async () => {