Play

Check-in [a29bc5e10b]
Login
Overview
Comment:Include member types of union when printing error message. Also fix implementation of list/fold. Still doesn't compile.
Timelines: family | ancestors | descendants | both | stdlib
Files: files | file ages | folders
SHA3-256: a29bc5e10b37309d3730066fa54b91f04e3af2a68a80b2d7c35ecc02c2dcf632
User & Date: robin.hansen on 2021-04-16 08:24:04
Other Links: branch diff | manifest | tags
Context
2021-04-16
08:25
Bad commit. check-in: 858d57ef6f user: robin.hansen tags: stdlib
08:24
Include member types of union when printing error message. Also fix implementation of list/fold. Sti... check-in: a29bc5e10b user: robin.hansen tags: stdlib
2021-04-15
09:55
Fix bug where type checker would remove generic from inferred output of a multi-function, if the sam... check-in: aee83f3ef4 user: robin.hansen tags: stdlib
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Play/Data/Type.elm from [7b6e93ee1b] to [7660e71094].

143
144
145
146
147
148
149
150






151


152
153
154
155
156
157
158

        Custom name ->
            name

        CustomGeneric name _ ->
            name

        Union _ ->






            "Union"



        Quotation quotType ->
            "[ " ++ wordTypeToString quotType ++ " ]"

        StackRange name ->
            name ++ "..."








|
>
>
>
>
>
>
|
>
>







143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

        Custom name ->
            name

        CustomGeneric name _ ->
            name

        Union members ->
            let
                memberString =
                    members
                        |> List.map toDisplayString
                        |> String.join ", "
            in
            "Union("
                ++ memberString
                ++ ")"

        Quotation quotType ->
            "[ " ++ wordTypeToString quotType ++ " ]"

        StackRange name ->
            name ++ "..."

Modified src/Play/TypeChecker/Problem.elm from [b183d4af4c] to [4e260c0773].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
                ++ "' needs to be declared."

        TypeError range name actual expected ->
            SourceLocation.extractFromString source range
                ++ "\n\n"
                ++ "The type of '"
                ++ name
                ++ "' is specified to be: "
                ++ Type.wordTypeToString actual
                ++ ".\nHowever, it seems that the actual type is: "
                ++ Type.wordTypeToString expected

        UnexpectedType range name actual expected ->
            SourceLocation.extractFromString source range
                ++ "\n\n"
                ++ "Found a problem in the implementation of '"
                ++ name
                ++ "'.\n\nExpected: "
                ++ Type.toDisplayString expected
                ++ ".\nActual: "
                ++ Type.toDisplayString actual
                ++ "."

        InconsistentWhens range name ->
            SourceLocation.extractFromString source range
                ++ "\n\n"
                ++ "The branches of '"
                ++ name
                ++ "' do not all have the same type."







|

|







|

|

<







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55
                ++ "' needs to be declared."

        TypeError range name actual expected ->
            SourceLocation.extractFromString source range
                ++ "\n\n"
                ++ "The type of '"
                ++ name
                ++ "' is specified to be:\n\n"
                ++ Type.wordTypeToString actual
                ++ "\n\nHowever, it seems that the actual type is: "
                ++ Type.wordTypeToString expected

        UnexpectedType range name actual expected ->
            SourceLocation.extractFromString source range
                ++ "\n\n"
                ++ "Found a problem in the implementation of '"
                ++ name
                ++ "'.\n\nExpected:\n\n"
                ++ Type.toDisplayString expected
                ++ "\n\nActual:\n"
                ++ Type.toDisplayString actual


        InconsistentWhens range name ->
            SourceLocation.extractFromString source range
                ++ "\n\n"
                ++ "The branches of '"
                ++ name
                ++ "' do not all have the same type."

Modified stdlib/src/list.play from [4f0302ab53] to [df2166b9d8].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
: Empty
  drop swap drop
: NonEmpty
  pair/>Pair
  swap # (Pair b quot) (NonEmpty a)
  [ first> ] [ rest> ] core/split # Pair first rest
  rotate swap # rest first Pair
  pair/spill # rest first b quot
  dup rotate # rest quot first b quot
  ! # rest quot b
  swap # rest b quot
  fold

def: test
: 1 2 3 Empty >NonEmpty >NonEmpty >NonEmpty
  0 [ + ] fold









|
|
|
|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
: Empty
  drop swap drop
: NonEmpty
  pair/>Pair
  swap # (Pair b quot) (NonEmpty a)
  [ first> ] [ rest> ] core/split # Pair first rest
  rotate swap # rest first Pair
  dup rotate # rest Pair first Pair
  pair/spill # rest Pair first b quot
  ! # rest Pair b
  swap pair/second> # rest b quot
  fold

def: test
: 1 2 3 Empty >NonEmpty >NonEmpty >NonEmpty
  0 [ + ] fold