Stabel

Check-in [8e8bc32982]
Login
Overview
Comment:, is now a valid function name.
Timelines: family | ancestors | descendants | both | module-definition
Files: files | file ages | folders
SHA3-256: 8e8bc32982a065b54259aa0818cf2bd4409e47a0a15d1b5cf6ac7845b6bde0d9
User & Date: robin.hansen on 2021-06-02 09:23:06
Other Links: branch diff | manifest | tags
Context
2021-06-02
09:59
Format errors from CLI. Closed-Leaf check-in: 742e0c8355 user: robin.hansen tags: module-definition
09:23
, is now a valid function name. check-in: 8e8bc32982 user: robin.hansen tags: module-definition
2021-06-01
10:34
Add default import on standard_library/core module. check-in: 74d477ef73 user: robin.hansen tags: module-definition
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Play/Parser.elm from [2e78bf7501] to [fcb864ece6].

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
        , '{'
        , '}'
        , '['
        , ']'
        , '('
        , ')'
        , '.'
        , ','
        , '#'
        , '/'
        ]


whitespaceChars : Set Char
whitespaceChars =







<







162
163
164
165
166
167
168

169
170
171
172
173
174
175
        , '{'
        , '}'
        , '['
        , ']'
        , '('
        , ')'
        , '.'

        , '#'
        , '/'
        ]


whitespaceChars : Set Char
whitespaceChars =

Modified src/Wasm.elm from [0c6d3e3be9] to [287b980b46].

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316

            else
                "(local " ++ (String.join " " <| List.map typeToString function.locals) ++ ")"

        fullFuncDef =
            String.join " "
                [ "(func"
                , "$" ++ function.name
                , "(type " ++ String.fromInt function.typeSignatureIndex ++ ")"
                , locals
                ]
    in
    [ Str fullFuncDef
    , Indent <| List.map (formatInstruction module_) function.instructions
    , Str ")"







|







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316

            else
                "(local " ++ (String.join " " <| List.map typeToString function.locals) ++ ")"

        fullFuncDef =
            String.join " "
                [ "(func"
                , "$" ++ String.replace "," "__COMMA__" function.name
                , "(type " ++ String.fromInt function.typeSignatureIndex ++ ")"
                , locals
                ]
    in
    [ Str fullFuncDef
    , Indent <| List.map (formatInstruction module_) function.instructions
    , Str ")"

Modified stdlib/src/list.play from [0c89385133] to [ac6dd828cb].

6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
..
34
35
36
37
38
39
40




41
42
43
44
45
46
47
  first>
  >rest
  rest>
  Empty
  of-one
  of-two
  of-three

  fold
  reverse
  fold-reverse
  test
:

defunion: List a
: NonEmpty a
: Empty

defstruct: NonEmpty a
................................................................................
type: a a -- (NonEmpty a)
: Empty >NonEmpty >NonEmpty

def: of-three
type: a a a -- (NonEmpty a)
: Empty >NonEmpty >NonEmpty >NonEmpty





defmulti: fold
type: (List a) b [ a b -- b ] -- b
: Empty
  drop swap drop
: NonEmpty
  pair/>Pair
  swap # (Pair b quot) (NonEmpty a)







>



<







 







>
>
>
>







6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
..
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  first>
  >rest
  rest>
  Empty
  of-one
  of-two
  of-three
  ,
  fold
  reverse
  fold-reverse

:

defunion: List a
: NonEmpty a
: Empty

defstruct: NonEmpty a
................................................................................
type: a a -- (NonEmpty a)
: Empty >NonEmpty >NonEmpty

def: of-three
type: a a a -- (NonEmpty a)
: Empty >NonEmpty >NonEmpty >NonEmpty

def: ,
type: (List a) a -- (NonEmpty a)
: swap >NonEmpty

defmulti: fold
type: (List a) b [ a b -- b ] -- b
: Empty
  drop swap drop
: NonEmpty
  pair/>Pair
  swap # (Pair b quot) (NonEmpty a)

Modified tests/Test/Parser.elm from [81204d11cf] to [e119fc8848].

123
124
125
126
127
128
129

























































130
131
132
133
134
135
136
                                        SoloImpl
                                            [ AST.Word emptyRange "-"
                                            , AST.Word emptyRange "zero?"
                                            ]
                                  }
                                ]
                        }

























































                in
                case compile source of
                    Err _ ->
                        Expect.fail "Did not expect parsing to fail"

                    Ok ast ->
                        Expect.equal expectedAst ast







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
                                        SoloImpl
                                            [ AST.Word emptyRange "-"
                                            , AST.Word emptyRange "zero?"
                                            ]
                                  }
                                ]
                        }
                in
                case compile source of
                    Err _ ->
                        Expect.fail "Did not expect parsing to fail"

                    Ok ast ->
                        Expect.equal expectedAst ast
        , test ", is a valid fn name" <|
            \_ ->
                let
                    source =
                        """
                        def: ,
                        type: Int Int -- Int
                        : +

                        def: add2
                        type: Int -- Int
                        : 2 ,
                        """

                    expectedAst =
                        { moduleDefinition = AST.emptyModuleDefinition
                        , types = Dict.empty
                        , words =
                            Dict.fromListBy .name
                                [ { name = ","
                                  , typeSignature =
                                        AST.UserProvided
                                            { input = [ AST.LocalRef "Int" [], AST.LocalRef "Int" [] ]
                                            , output = [ AST.LocalRef "Int" [] ]
                                            }
                                  , sourceLocationRange = Nothing
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation =
                                        SoloImpl
                                            [ AST.Word emptyRange "+"
                                            ]
                                  }
                                , { name = "add2"
                                  , typeSignature =
                                        AST.UserProvided
                                            { input = [ AST.LocalRef "Int" [] ]
                                            , output = [ AST.LocalRef "Int" [] ]
                                            }
                                  , sourceLocationRange = Nothing
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation =
                                        SoloImpl
                                            [ AST.Integer emptyRange 2
                                            , AST.Word emptyRange ","
                                            ]
                                  }
                                ]
                        }
                in
                case compile source of
                    Err _ ->
                        Expect.fail "Did not expect parsing to fail"

                    Ok ast ->
                        Expect.equal expectedAst ast