Stabel

Check-in [f6408f42e9]
Login
Overview
Comment:Parser and Qualifier updated with new type match structure.
Timelines: family | ancestors | descendants | both | int-literals-in-pattern-match
Files: files | file ages | folders
SHA3-256: f6408f42e9af7c1e76cd0d1be42225ea1b8a37565a89faafe56b2e51dc15774d
User & Date: robin.hansen on 2021-09-22 09:12:01
Other Links: branch diff | manifest | tags
Context
2021-09-22
10:11
TypeChecker is ported over. Exhaustiveness checking tests are failing. check-in: efd95fdaff user: robin.hansen tags: int-literals-in-pattern-match
09:12
Parser and Qualifier updated with new type match structure. check-in: f6408f42e9 user: robin.hansen tags: int-literals-in-pattern-match
2021-09-21
17:37
Attempted syntax sugar approach for supporting int literals as pattern match, but it causes codegen ... check-in: 8bbd6d2ddc user: robin.hansen tags: int-literals-in-pattern-match
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Stabel/Parser.elm from [c836706185] to [bbf63e8a58].

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
....
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
....
1358
1359
1360
1361
1362
1363
1364
1365





1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
    ( AST
    , AstNode(..)
    , FunctionDefinition
    , FunctionImplementation(..)
    , TypeDefinition
    , TypeDefinitionMembers(..)
    , TypeMatch(..)
    , TypeMatchValue(..)
    , run
    )

import Bitwise
import Dict exposing (Dict)
import Dict.Extra as Dict
import List.Extra as List
................................................................................
type FunctionImplementation
    = SoloImpl (List AstNode)
    | MultiImpl (List ( TypeMatch, List AstNode )) (List AstNode)


type TypeMatch
    = TypeMatchInt SourceLocationRange Int
    | TypeMatchType SourceLocationRange PossiblyQualifiedType (List ( String, TypeMatchValue ))


type TypeMatchValue
    = LiteralType PossiblyQualifiedType
    | RecursiveMatch TypeMatch


type AstNode
    = Integer SourceLocationRange Int
    | Function SourceLocationRange String
    | PackageFunction SourceLocationRange (List String) String
    | ExternalFunction SourceLocationRange (List String) String
................................................................................
typeMatchParser : Parser TypeMatch
typeMatchParser =
    Parser.oneOf
        [ Parser.succeed (\startLoc int endLoc -> TypeMatchInt (SourceLocationRange startLoc endLoc) int)
            |= sourceLocationParser
            |= intParser
            |= sourceLocationParser
        , Parser.succeed (\startLoc type_ conds endLoc -> TypeMatchType (SourceLocationRange startLoc endLoc) type_ conds)
            |= sourceLocationParser
            |= typeMatchTypeParser
            |= Parser.oneOf
                [ Parser.succeed identity
                    |. Parser.symbol (Token "(" ExpectedLeftParen)
                    |. noiseParser
                    |= Parser.loop [] typeMatchConditionParser
................................................................................
                    |. Parser.symbol (Token ")" ExpectedRightParen)
                , Parser.succeed []
                ]
            |= sourceLocationParser
        ]


typeMatchConditionParser : List ( String, TypeMatchValue ) -> Parser (Parser.Step (List ( String, TypeMatchValue )) (List ( String, TypeMatchValue )))





typeMatchConditionParser nodes =
    Parser.oneOf
        [ Parser.succeed (\name value -> Parser.Loop (( name, value ) :: nodes))
            |= symbolParser
            |. noiseParser
            |= typeMatchValueParser
            |. noiseParser
        , Parser.succeed (Parser.Done (List.reverse nodes))
        ]


typeMatchValueParser : Parser TypeMatchValue
typeMatchValueParser =
    let
        handleNewType match =
            case match of
                TypeMatchType _ type_ [] ->
                    LiteralType type_

                _ ->
                    RecursiveMatch match
    in
    Parser.succeed handleNewType
        |= typeMatchParser


implementationParser : Parser (List AstNode)
implementationParser =
    Parser.loop [] implementationParserHelp


implementationParserHelp : List AstNode -> Parser (Parser.Step (List AstNode) (List AstNode))







<







 







|
<
<
<
<
<







 







|







 







|
>
>
>
>
>





|




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







2
3
4
5
6
7
8

9
10
11
12
13
14
15
..
68
69
70
71
72
73
74
75





76
77
78
79
80
81
82
....
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
....
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374















1375
1376
1377
1378
1379
1380
1381
    ( AST
    , AstNode(..)
    , FunctionDefinition
    , FunctionImplementation(..)
    , TypeDefinition
    , TypeDefinitionMembers(..)
    , TypeMatch(..)

    , run
    )

import Bitwise
import Dict exposing (Dict)
import Dict.Extra as Dict
import List.Extra as List
................................................................................
type FunctionImplementation
    = SoloImpl (List AstNode)
    | MultiImpl (List ( TypeMatch, List AstNode )) (List AstNode)


type TypeMatch
    = TypeMatchInt SourceLocationRange Int
    | TypeMatchType SourceLocationRange PossiblyQualifiedType (List ( String, TypeMatch ))







type AstNode
    = Integer SourceLocationRange Int
    | Function SourceLocationRange String
    | PackageFunction SourceLocationRange (List String) String
    | ExternalFunction SourceLocationRange (List String) String
................................................................................
typeMatchParser : Parser TypeMatch
typeMatchParser =
    Parser.oneOf
        [ Parser.succeed (\startLoc int endLoc -> TypeMatchInt (SourceLocationRange startLoc endLoc) int)
            |= sourceLocationParser
            |= intParser
            |= sourceLocationParser
        , Parser.succeed typeMatchTypeHelper
            |= sourceLocationParser
            |= typeMatchTypeParser
            |= Parser.oneOf
                [ Parser.succeed identity
                    |. Parser.symbol (Token "(" ExpectedLeftParen)
                    |. noiseParser
                    |= Parser.loop [] typeMatchConditionParser
................................................................................
                    |. Parser.symbol (Token ")" ExpectedRightParen)
                , Parser.succeed []
                ]
            |= sourceLocationParser
        ]


typeMatchTypeHelper : SourceLocation -> PossiblyQualifiedType -> List ( String, TypeMatch ) -> SourceLocation -> TypeMatch
typeMatchTypeHelper startLoc type_ conds endLoc =
    TypeMatchType (SourceLocationRange startLoc endLoc) type_ conds


typeMatchConditionParser : List ( String, TypeMatch ) -> Parser (Parser.Step (List ( String, TypeMatch )) (List ( String, TypeMatch )))
typeMatchConditionParser nodes =
    Parser.oneOf
        [ Parser.succeed (\name value -> Parser.Loop (( name, value ) :: nodes))
            |= symbolParser
            |. noiseParser
            |= typeMatchParser
            |. noiseParser
        , Parser.succeed (Parser.Done (List.reverse nodes))
        ]

















implementationParser : Parser (List AstNode)
implementationParser =
    Parser.loop [] implementationParserHelp


implementationParserHelp : List AstNode -> Parser (Parser.Step (List AstNode) (List AstNode))

Modified src/Stabel/Qualifier.elm from [851ada32fd] to [186078bf1d].

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
71
72
73
74
75
76
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923






924


925
926
927
928



929
930
931
932
933
934
935
...
951
952
953
954
955
956
957




958


959
960
961
962
963
964
965
966
967




968


969
970
971
972
973
974
975
976
977




978


979
980
981
982
983
984
985
986
987
988
989




990


991
992
993
994
995
996

997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009

1010
1011









1012


1013
1014


1015




1016










1017

1018


1019
1020
























1021
1022
1023
1024
1025
1026
1027
1028
1029

1030
1031
1032
1033
1034
1035
1036
    , FunctionDefinition
    , FunctionImplementation(..)
    , Node(..)
    , RunConfig
    , TypeDefinition
    , TypeDefinitionMembers(..)
    , TypeMatch(..)
    , TypeMatchCond(..)
    , TypeMatchValue(..)
    , requiredModules
    , run
    )

import Dict exposing (Dict)
import List.Extra as List
import Result.Extra as Result
................................................................................

type FunctionImplementation
    = SoloImpl (List Node)
    | MultiImpl (List ( TypeMatch, List Node )) (List Node)


type TypeMatch

    = TypeMatch SourceLocationRange Type (List TypeMatchCond)


type TypeMatchCond
    = TypeMatchCond String Type TypeMatchValue


type TypeMatchValue
    = LiteralInt Int
    | LiteralType Type
    | RecursiveMatch TypeMatch


type Node
    = Integer SourceLocationRange Int
    | Function SourceLocationRange FunctionDefinition
    | FunctionRef SourceLocationRange FunctionDefinition
    | Recurse SourceLocationRange
................................................................................
qualifyMatch config qualifiedTypes modRefs typeMatch =
    let
        qualifiedRange range =
            SourceLocationRange
                config.ast.sourceReference
                range.start
                range.end

        qualifiedNameToMatch range name patterns =
            case Dict.get name qualifiedTypes of
                Just typeDef ->
                    if not typeDef.exposed then
                        Err <| TypeNotExposed range name

                    else
                        case typeDef.members of
                            StructMembers members ->
                                let
                                    qualifiedPatternsResult =
                                        patterns
                                            |> List.map
                                                (qualifyMatchValue
                                                    config
                                                    qualifiedTypes
                                                    modRefs
                                                    range
                                                    name
                                                    members
                                                )
                                            |> Result.combine

                                    actualType =
                                        case typeDef.generics of
                                            [] ->
                                                Type.Custom name

                                            _ ->
                                                Type.CustomGeneric
                                                    name
                                                    (List.map Type.Generic typeDef.generics)
                                in
                                case qualifiedPatternsResult of
                                    Ok qualifiedPatterns ->
                                        Ok <| TypeMatch range actualType qualifiedPatterns

                                    Err err ->
                                        Err err

                            UnionMembers types ->
                                if List.isEmpty patterns then
                                    Ok <| TypeMatch range (Type.Union (Just name) types) []

                                else
                                    Err <| UnionTypeMatchWithPatterns range

                Nothing ->
                    Err <| UnknownTypeRef range name
    in
    case typeMatch of
        Parser.TypeMatchInt range val ->
            Ok <|
                TypeMatch
                    (qualifiedRange range)
                    Type.Int
                    [ TypeMatchCond "value" Type.Int (LiteralInt val) ]

        Parser.TypeMatchType range (Parser.LocalRef "Int" []) [] ->
            Ok <| TypeMatch (qualifiedRange range) Type.Int []

        Parser.TypeMatchType range (Parser.LocalRef "Array" []) [] ->
            Ok <|
                TypeMatch
                    (qualifiedRange range)
                    (Type.Array (Type.Generic "*a"))
                    []

        Parser.TypeMatchType range (Parser.Generic sym) [] ->
            Ok <| TypeMatch (qualifiedRange range) (Type.Generic sym) []

        Parser.TypeMatchType range (Parser.LocalRef name []) patterns ->






            case qualifiedNameToMatch (qualifiedRange range) (qualifyName config name) patterns of


                (Err (UnknownTypeRef _ _)) as errMsg ->
                    case resolveImportedType config modRefs name of
                        Just importedModule ->
                            qualifiedNameToMatch



                                (qualifiedRange range)
                                (importedModule ++ "/" ++ name)
                                patterns

                        Nothing ->
                            errMsg

................................................................................
                        let
                            qualifiedName =
                                actualPath
                                    ++ "/"
                                    ++ name
                                    |> qualifyPackageModule config.packageName
                        in




                        qualifiedNameToMatch (qualifiedRange range) qualifiedName patterns



                Nothing ->
                    let
                        qualifiedName =
                            possibleAlias
                                ++ "/"
                                ++ name
                                |> qualifyPackageModule config.packageName
                    in




                    qualifiedNameToMatch (qualifiedRange range) qualifiedName patterns



        Parser.TypeMatchType range (Parser.InternalRef path name _) patterns ->
            let
                qualifiedName =
                    path
                        ++ [ name ]
                        |> String.join "/"
                        |> qualifyPackageModule config.packageName
            in




            qualifiedNameToMatch (qualifiedRange range) qualifiedName patterns



        Parser.TypeMatchType range (Parser.ExternalRef path name _) patterns ->
            let
                pathString =
                    "/" ++ String.join "/" path

                qualifiedName =
                    Dict.get pathString config.externalModules
                        |> Maybe.map (\prefix -> "/" ++ prefix ++ pathString ++ "/" ++ name)
                        |> Maybe.withDefault ""
            in




            qualifiedNameToMatch (qualifiedRange range) qualifiedName patterns



        Parser.TypeMatchType range _ _ ->
            Err <| InvalidTypeMatch (qualifiedRange range)


qualifyMatchValue :

    RunConfig
    -> Dict String TypeDefinition
    -> ModuleReferences
    -> SourceLocationRange
    -> String
    -> List ( String, Type )
    -> ( String, Parser.TypeMatchValue )
    -> Result Problem TypeMatchCond
qualifyMatchValue config qualifiedTypes modRefs range typeName members ( fieldName, matchValue ) =
    case List.find ((==) fieldName << Tuple.first) members of
        Just ( _, fieldType ) ->
            case matchValue of
                Parser.LiteralType type_ ->

                    type_
                        |> qualifyMemberType config modRefs range









                        |> Result.map


                            (\qualifiedType ->
                                TypeMatchCond


                                    fieldName




                                    fieldType










                                    (LiteralType qualifiedType)

                            )



                Parser.RecursiveMatch typeMatch ->
























                    typeMatch
                        |> qualifyMatch config qualifiedTypes modRefs
                        |> Result.map
                            (\match ->
                                TypeMatchCond
                                    fieldName
                                    fieldType
                                    (RecursiveMatch match)
                            )


        _ ->
            Err <| NoSuchMemberOnType range typeName fieldName


initQualifyNode :
    RunConfig







<
<







 







>
|
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
<
|
<
<


|



|





|


>
>
>
>
>
>
|
>
>




>
>
>







 







>
>
>
>
|
>
>









>
>
>
>
|
>
>









>
>
>
>
|
>
>











>
>
>
>
|
>
>





<
>





<
|
|
|
<
<
<
<
>
|
<
>
>
>
>
>
>
>
>
>
|
>
>
|
<
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>

<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
<
|
<
|
|
>







4
5
6
7
8
9
10


11
12
13
14
15
16
17
..
69
70
71
72
73
74
75
76
77










78
79
80
81
82
83
84
...
833
834
835
836
837
838
839

































840

















841
842


843


844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
...
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965

966
967
968
969
970
971

972
973
974




975
976

977
978
979
980
981
982
983
984
985
986
987
988
989

990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013

1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041

1042

1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
    , FunctionDefinition
    , FunctionImplementation(..)
    , Node(..)
    , RunConfig
    , TypeDefinition
    , TypeDefinitionMembers(..)
    , TypeMatch(..)


    , requiredModules
    , run
    )

import Dict exposing (Dict)
import List.Extra as List
import Result.Extra as Result
................................................................................

type FunctionImplementation
    = SoloImpl (List Node)
    | MultiImpl (List ( TypeMatch, List Node )) (List Node)


type TypeMatch
    = TypeMatchInt SourceLocationRange Int
    | TypeMatchType SourceLocationRange Type (List ( String, TypeMatch ))












type Node
    = Integer SourceLocationRange Int
    | Function SourceLocationRange FunctionDefinition
    | FunctionRef SourceLocationRange FunctionDefinition
    | Recurse SourceLocationRange
................................................................................
qualifyMatch config qualifiedTypes modRefs typeMatch =
    let
        qualifiedRange range =
            SourceLocationRange
                config.ast.sourceReference
                range.start
                range.end

































    in

















    case typeMatch of
        Parser.TypeMatchInt range val ->


            Ok <| TypeMatchInt (qualifiedRange range) val



        Parser.TypeMatchType range (Parser.LocalRef "Int" []) [] ->
            Ok <| TypeMatchType (qualifiedRange range) Type.Int []

        Parser.TypeMatchType range (Parser.LocalRef "Array" []) [] ->
            Ok <|
                TypeMatchType
                    (qualifiedRange range)
                    (Type.Array (Type.Generic "*a"))
                    []

        Parser.TypeMatchType range (Parser.Generic sym) [] ->
            Ok <| TypeMatchType (qualifiedRange range) (Type.Generic sym) []

        Parser.TypeMatchType range (Parser.LocalRef name []) patterns ->
            case
                qualifiedNameToMatch
                    config
                    qualifiedTypes
                    modRefs
                    (qualifiedRange range)
                    (qualifyName config name)
                    patterns
            of
                (Err (UnknownTypeRef _ _)) as errMsg ->
                    case resolveImportedType config modRefs name of
                        Just importedModule ->
                            qualifiedNameToMatch
                                config
                                qualifiedTypes
                                modRefs
                                (qualifiedRange range)
                                (importedModule ++ "/" ++ name)
                                patterns

                        Nothing ->
                            errMsg

................................................................................
                        let
                            qualifiedName =
                                actualPath
                                    ++ "/"
                                    ++ name
                                    |> qualifyPackageModule config.packageName
                        in
                        qualifiedNameToMatch
                            config
                            qualifiedTypes
                            modRefs
                            (qualifiedRange range)
                            qualifiedName
                            patterns

                Nothing ->
                    let
                        qualifiedName =
                            possibleAlias
                                ++ "/"
                                ++ name
                                |> qualifyPackageModule config.packageName
                    in
                    qualifiedNameToMatch
                        config
                        qualifiedTypes
                        modRefs
                        (qualifiedRange range)
                        qualifiedName
                        patterns

        Parser.TypeMatchType range (Parser.InternalRef path name _) patterns ->
            let
                qualifiedName =
                    path
                        ++ [ name ]
                        |> String.join "/"
                        |> qualifyPackageModule config.packageName
            in
            qualifiedNameToMatch
                config
                qualifiedTypes
                modRefs
                (qualifiedRange range)
                qualifiedName
                patterns

        Parser.TypeMatchType range (Parser.ExternalRef path name _) patterns ->
            let
                pathString =
                    "/" ++ String.join "/" path

                qualifiedName =
                    Dict.get pathString config.externalModules
                        |> Maybe.map (\prefix -> "/" ++ prefix ++ pathString ++ "/" ++ name)
                        |> Maybe.withDefault ""
            in
            qualifiedNameToMatch
                config
                qualifiedTypes
                modRefs
                (qualifiedRange range)
                qualifiedName
                patterns

        Parser.TypeMatchType range _ _ ->
            Err <| InvalidTypeMatch (qualifiedRange range)



qualifiedNameToMatch :
    RunConfig
    -> Dict String TypeDefinition
    -> ModuleReferences
    -> SourceLocationRange
    -> String

    -> List ( String, Parser.TypeMatch )
    -> Result Problem TypeMatch
qualifiedNameToMatch config qualifiedTypes modRefs range name patterns =




    case Dict.get name qualifiedTypes of
        Just typeDef ->

            if not typeDef.exposed then
                Err <| TypeNotExposed range name

            else
                case typeDef.members of
                    StructMembers members ->
                        let
                            qualifiedPatternsResult =
                                patterns
                                    |> List.map
                                        (qualifyMatchValue
                                            config
                                            qualifiedTypes

                                            modRefs
                                            range
                                            name
                                            members
                                        )
                                    |> Result.combine

                            actualType =
                                case typeDef.generics of
                                    [] ->
                                        Type.Custom name

                                    _ ->
                                        Type.CustomGeneric
                                            name
                                            (List.map Type.Generic typeDef.generics)
                        in
                        case qualifiedPatternsResult of
                            Ok qualifiedPatterns ->
                                Ok <| TypeMatchType range actualType qualifiedPatterns

                            Err err ->
                                Err err


                    UnionMembers types ->
                        case patterns of
                            [] ->
                                Ok <| TypeMatchType range (Type.Union (Just name) types) []

                            _ ->
                                Err <| UnionTypeMatchWithPatterns range

        Nothing ->
            Err <| UnknownTypeRef range name


qualifyMatchValue :
    RunConfig
    -> Dict String TypeDefinition
    -> ModuleReferences
    -> SourceLocationRange
    -> String
    -> List ( String, Type )
    -> ( String, Parser.TypeMatch )
    -> Result Problem ( String, TypeMatch )
qualifyMatchValue config qualifiedTypes modRefs range typeName members ( fieldName, matchValue ) =
    case List.find ((==) fieldName << Tuple.first) members of
        Just _ ->
            matchValue
                |> qualifyMatch config qualifiedTypes modRefs
                |> Result.map
                    (\match ->

                        ( fieldName

                        , match
                        )
                    )

        _ ->
            Err <| NoSuchMemberOnType range typeName fieldName


initQualifyNode :
    RunConfig

Modified tests/Test/Parser.elm from [46f7896150] to [e6646f0f1b].

1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027

1028
1029
1030
1031
1032
1033
1034
1035
1036
....
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
                                      , aliases = Dict.empty
                                      , imports = Dict.empty
                                      , implementation =
                                            MultiImpl
                                                [ ( TypeMatchType emptyRange
                                                        (LocalRef "List" [])
                                                        [ ( "tail"
                                                          , AST.RecursiveMatch
                                                                (TypeMatchType emptyRange
                                                                    (LocalRef "List" [])
                                                                    [ ( "tail", AST.LiteralType (LocalRef "Nil" []) )

                                                                    ]
                                                                )
                                                          )
                                                        ]
                                                  , [ AST.Function emptyRange "True" ]
                                                  )
                                                ]
                                                [ AST.Function emptyRange "False" ]
                                      }
................................................................................
                                      , documentation = ""
                                      , aliases = Dict.empty
                                      , imports = Dict.empty
                                      , implementation =
                                            MultiImpl
                                                [ ( TypeMatchType emptyRange
                                                        (LocalRef "Pair" [])
                                                        [ ( "first", RecursiveMatch <| TypeMatchInt emptyRange 0 )
                                                        , ( "second", RecursiveMatch <| TypeMatchInt emptyRange 0 )
                                                        ]
                                                  , [ AST.Function emptyRange "True" ]
                                                  )
                                                ]
                                                [ AST.Function emptyRange "False" ]
                                      }
                                    ]







<
|
|
<
>
|
<







 







|
|







1017
1018
1019
1020
1021
1022
1023

1024
1025

1026
1027

1028
1029
1030
1031
1032
1033
1034
....
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
                                      , aliases = Dict.empty
                                      , imports = Dict.empty
                                      , implementation =
                                            MultiImpl
                                                [ ( TypeMatchType emptyRange
                                                        (LocalRef "List" [])
                                                        [ ( "tail"

                                                          , TypeMatchType emptyRange
                                                                (LocalRef "List" [])

                                                                [ ( "tail", TypeMatchType emptyRange (LocalRef "Nil" []) [] )
                                                                ]

                                                          )
                                                        ]
                                                  , [ AST.Function emptyRange "True" ]
                                                  )
                                                ]
                                                [ AST.Function emptyRange "False" ]
                                      }
................................................................................
                                      , documentation = ""
                                      , aliases = Dict.empty
                                      , imports = Dict.empty
                                      , implementation =
                                            MultiImpl
                                                [ ( TypeMatchType emptyRange
                                                        (LocalRef "Pair" [])
                                                        [ ( "first", TypeMatchInt emptyRange 0 )
                                                        , ( "second", TypeMatchInt emptyRange 0 )
                                                        ]
                                                  , [ AST.Function emptyRange "True" ]
                                                  )
                                                ]
                                                [ AST.Function emptyRange "False" ]
                                      }
                                    ]

Modified tests/Test/Parser/QualifiedRefs.elm from [cf2cf9f2d4] to [b5b2da8cf8].

202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
...
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatchType emptyRange (ExternalRef [ "external" ] "Tipe" []) [ ( "value", RecursiveMatch <| TypeMatchInt emptyRange 1 ) ]
                                              , [ AST.Function emptyRange "drop"
                                                , AST.Integer emptyRange 1
                                                ]
                                              )
                                            ]
                                            [ AST.Function emptyRange "drop"
                                            , AST.Integer emptyRange 0
................................................................................
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatchType emptyRange (InternalRef [ "internal" ] "Tipe" []) [ ( "value", RecursiveMatch <| TypeMatchInt emptyRange 1 ) ]
                                              , [ AST.Function emptyRange "drop"
                                                , AST.Integer emptyRange 1
                                                ]
                                              )
                                            ]
                                            [ AST.Function emptyRange "drop"
                                            , AST.Integer emptyRange 0







|







 







|







202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
...
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatchType emptyRange (ExternalRef [ "external" ] "Tipe" []) [ ( "value", TypeMatchInt emptyRange 1 ) ]
                                              , [ AST.Function emptyRange "drop"
                                                , AST.Integer emptyRange 1
                                                ]
                                              )
                                            ]
                                            [ AST.Function emptyRange "drop"
                                            , AST.Integer emptyRange 0
................................................................................
                                            }
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation =
                                        MultiImpl
                                            [ ( TypeMatchType emptyRange (InternalRef [ "internal" ] "Tipe" []) [ ( "value", TypeMatchInt emptyRange 1 ) ]
                                              , [ AST.Function emptyRange "drop"
                                                , AST.Integer emptyRange 1
                                                ]
                                              )
                                            ]
                                            [ AST.Function emptyRange "drop"
                                            , AST.Integer emptyRange 0

Modified tests/Test/Parser/Util.elm from [d2a2df77af] to [d2ff50d105].

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
stripTypeMatchLocation match =
    case match of
        TypeMatchInt _ int ->
            TypeMatchInt emptyRange int

        TypeMatchType _ type_ otherConds ->
            TypeMatchType emptyRange type_ <|
                List.map (Tuple.mapSecond stripRecursiveTypeMatchLocation) otherConds


stripRecursiveTypeMatchLocation : TypeMatchValue -> TypeMatchValue
stripRecursiveTypeMatchLocation typeMatchValue =
    case typeMatchValue of
        RecursiveMatch typeMatch ->
            RecursiveMatch (stripTypeMatchLocation typeMatch)

        _ ->
            typeMatchValue


addFunctionsForStructs : AST -> AST
addFunctionsForStructs ast =
    let
        helper _ t wipAst =
            case t.members of







|
<
<
<
<
<
<
<
<
<
<







103
104
105
106
107
108
109
110










111
112
113
114
115
116
117
stripTypeMatchLocation match =
    case match of
        TypeMatchInt _ int ->
            TypeMatchInt emptyRange int

        TypeMatchType _ type_ otherConds ->
            TypeMatchType emptyRange type_ <|
                List.map (Tuple.mapSecond stripTypeMatchLocation) otherConds












addFunctionsForStructs : AST -> AST
addFunctionsForStructs ast =
    let
        helper _ t wipAst =
            case t.members of