@@ -21,7 +21,7 @@ as SML/NJ to get nice trees.
23import Control.Arrow (second)
23import Control.Arrow (second)
24−import Control.Monad (liftM, liftM2, liftM4)
24+import Control.Monad (liftM, liftM2, liftM5)
25import Data.Binary
25import Data.Binary
26import qualified Data.List as List
26import qualified Data.List as List
27import qualified Data.Maybe as Maybe
27import qualified Data.Maybe as Maybe
@@ -29,6 +29,7 @@ import qualified Data.Set as Set
29import Data.Text (Text)
29import Data.Text (Text)
31import qualified AST.Canonical as Can
31import qualified AST.Canonical as Can
32+import qualified AST.Module.Name as ModuleName
32import qualified Data.Index as Index
33import qualified Data.Index as Index
33import qualified Elm.Name as N
34import qualified Elm.Name as N
34import qualified Reporting.Annotation as A
35import qualified Reporting.Annotation as A
@@ -71,7 +72,7 @@ data DecisionTree
74− = IsCtor N.Name Index.ZeroBased Int Can.CtorOpts
75+ = IsCtor ModuleName.Canonical N.Name Index.ZeroBased Int Can.CtorOpts
@@ -137,7 +138,7 @@ toDecisionTree rawBranches =
137isComplete :: [Test] -> Bool
138isComplete :: [Test] -> Bool
138isComplete tests =
139isComplete tests =
139 case head tests of
140 case head tests of
140− IsCtor _ _ numAlts _ ->
141+ IsCtor _ _ _ numAlts _ ->
141 numAlts == length tests
142 numAlts == length tests
143 IsCons ->
144 IsCons ->
@@ -307,8 +308,8 @@ testAtPath selectedPath (Branch _ pathPatterns) =
308 Just (A.At _ pattern) ->
309 Just (A.At _ pattern) ->
309 case pattern of
310 case pattern of
310− Can.PCtor _ _ (Can.Union _ _ numAlts opts) name index _ ->
311+ Can.PCtor home _ (Can.Union _ _ numAlts opts) name index _ ->
311− Just (IsCtor name index numAlts opts)
312+ Just (IsCtor home name index numAlts opts)
313 Can.PList ps ->
314 Can.PList ps ->
314 Just (case ps of { [] -> IsNil ; _ -> IsCons })
315 Just (case ps of { [] -> IsNil ; _ -> IsCons })
@@ -362,7 +363,7 @@ toRelevantBranch test path branch@(Branch goal pathPatterns) =
362 case pattern of
363 case pattern of
363 Can.PCtor _ _ (Can.Union _ _ numAlts _) name _ ctorArgs ->
364 Can.PCtor _ _ (Can.Union _ _ numAlts _) name _ ctorArgs ->
364 case test of
365 case test of
365− IsCtor testName _ _ _ | name == testName ->
366+ IsCtor _ testName _ _ _ | name == testName ->
366 Just $ Branch goal $
367 Just $ Branch goal $
367 case map dearg ctorArgs of
368 case map dearg ctorArgs of
368 [arg] | numAlts == 1 ->
369 [arg] | numAlts == 1 ->
@@ -578,18 +579,18 @@ smallBranchingFactor branches path =
578instance Binary Test where
579instance Binary Test where
579 put test =
580 put test =
580 case test of
581 case test of
581− IsCtor a b c d -> putWord8 0 >> put a >> put b >> put c >> put d
582+ IsCtor a b c d e -> putWord8 0 >> put a >> put b >> put c >> put d >> put e
582− IsCons -> putWord8 1
583+ IsCons -> putWord8 1
583− IsNil -> putWord8 2
584+ IsNil -> putWord8 2
584− IsTuple -> putWord8 3
585+ IsTuple -> putWord8 3
585− IsChr a -> putWord8 4 >> put a
586+ IsChr a -> putWord8 4 >> put a
586− IsStr a -> putWord8 5 >> put a
587+ IsStr a -> putWord8 5 >> put a
587− IsInt a -> putWord8 6 >> put a
588+ IsInt a -> putWord8 6 >> put a
590 do word <- getWord8
591 do word <- getWord8
591 case word of
592 case word of
592− 0 -> liftM4 IsCtor get get get get
593+ 0 -> liftM5 IsCtor get get get get get
593 1 -> pure IsCons
594 1 -> pure IsCons
594 2 -> pure IsNil
595 2 -> pure IsNil
595 3 -> pure IsTuple
596 3 -> pure IsTuple