diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a268e32f8..0e7d26535 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,9 +41,9 @@ jobs: unison-core/.stack-work yaks/easytest/.stack-work # Main cache key: commit hash. This should always result in a cache miss... - key: stack-work-0_${{matrix.os}}-${{github.sha}} + key: stack-work-1_${{matrix.os}}-${{github.sha}} # ...but then fall back on the latest cache stored (on this branch) - restore-keys: stack-work-0_${{matrix.os}}- + restore-keys: stack-work-1_${{matrix.os}}- # Install stack by downloading the binary from GitHub. The installation process is different for Linux and macOS, # so this is split into two steps, only one of which will run on any particular build. diff --git a/parser-typechecker/src/Unison/Codebase/Conversion/Sync12.hs b/parser-typechecker/src/Unison/Codebase/Conversion/Sync12.hs index 1de51313a..8ef7a60c8 100644 --- a/parser-typechecker/src/Unison/Codebase/Conversion/Sync12.hs +++ b/parser-typechecker/src/Unison/Codebase/Conversion/Sync12.hs @@ -295,7 +295,7 @@ checkTermComponent t h n = do typeDeps = Type.dependencies typ let checkDecl = \case Reference.Builtin {} -> pure () - Reference.DerivedId (Reference.Id h' _ n') -> + Reference.Derived h' _ n' -> getDeclStatus h' >>= \case Just DeclOk -> pure () Just _ -> Except.throwError TermMissingDependencies @@ -303,10 +303,10 @@ checkTermComponent t h n = do checkTerm = \case Reference.Builtin {} -> pure () - Reference.DerivedId (Reference.Id h' _ _) + Reference.Derived h' _ _ | h == h' -> pure () -- ignore self-references - Reference.DerivedId (Reference.Id h' _ n') -> + Reference.Derived h' _ n' -> getTermStatus h' >>= \case Just TermOk -> pure () Just _ -> Except.throwError TermMissingDependencies @@ -330,7 +330,7 @@ checkWatchComponent t k r@(Reference.Id h _ _) = do let deps = Term.labeledDependencies watchResult let checkDecl = \case Reference.Builtin {} -> pure () - Reference.DerivedId (Reference.Id h' _ n') -> + Reference.Derived h' _ n' -> getDeclStatus h' >>= \case Just DeclOk -> pure () Just _ -> Except.throwError WatchMissingDependencies @@ -338,10 +338,10 @@ checkWatchComponent t k r@(Reference.Id h _ _) = do checkTerm = \case Reference.Builtin {} -> pure () - Reference.DerivedId (Reference.Id h' _ _) + Reference.Derived h' _ _ | h == h' -> pure () -- ignore self-references - Reference.DerivedId (Reference.Id h' _ n') -> + Reference.Derived h' _ n' -> getTermStatus h' >>= \case Just TermOk -> pure () Just _ -> Except.throwError WatchMissingDependencies @@ -366,8 +366,8 @@ checkDeclComponent t h n = do let deps = DD.declDependencies decl checkDecl = \case Reference.Builtin {} -> pure () - Reference.DerivedId (Reference.Id h' _ _) | h == h' -> pure () - Reference.DerivedId (Reference.Id h' _ n') -> + Reference.Derived h' _ _ | h == h' -> pure () + Reference.Derived h' _ n' -> getDeclStatus h' >>= \case Just DeclOk -> pure () Just _ -> Except.throwError DeclMissingDependencies @@ -450,14 +450,14 @@ repairPatch (Patch termEdits typeEdits) = do -- reference to it. See Sync22.syncPatchLocalIds helpTermEdit = \case Reference.Builtin _ -> pure True - Reference.DerivedId (Reference.Id h _ n) -> + Reference.Derived h _ n -> getTermStatus h >>= \case Nothing -> Validate.refute . Set.singleton $ T h n Just TermOk -> pure True Just _ -> pure False helpTypeEdit = \case Reference.Builtin _ -> pure True - Reference.DerivedId (Reference.Id h _ n) -> + Reference.Derived h _ n -> getDeclStatus h >>= \case Nothing -> Validate.refute . Set.singleton $ D h n Just DeclOk -> pure True @@ -506,7 +506,7 @@ validateTermReferent = \case validateTermReference :: (S m n, V m n) => Reference.Reference -> n Bool validateTermReference = \case Reference.Builtin {} -> pure True - Reference.DerivedId (Reference.Id h _i n) -> + Reference.Derived h _i n -> getTermStatus h >>= \case Nothing -> Validate.refute . Set.singleton $ T h n Just TermOk -> pure True @@ -515,7 +515,7 @@ validateTermReference = \case validateTypeReference :: (S m n, V m n) => Reference.Reference -> n Bool validateTypeReference = \case Reference.Builtin {} -> pure True - Reference.DerivedId (Reference.Id h _i n) -> + Reference.Derived h _i n -> getDeclStatus h >>= \case Nothing -> Validate.refute . Set.singleton $ D h n Just DeclOk -> pure True diff --git a/parser-typechecker/src/Unison/Codebase/Serialization/V1.hs b/parser-typechecker/src/Unison/Codebase/Serialization/V1.hs index ecb7b0754..7793eff07 100644 --- a/parser-typechecker/src/Unison/Codebase/Serialization/V1.hs +++ b/parser-typechecker/src/Unison/Codebase/Serialization/V1.hs @@ -239,7 +239,6 @@ putReference r = case r of putHash hash putLength i putLength n - _ -> error "unpossible" getReference :: MonadGet m => m Reference getReference = do diff --git a/parser-typechecker/src/Unison/Codecs.hs b/parser-typechecker/src/Unison/Codecs.hs index f1dceddc1..85c85ed88 100644 --- a/parser-typechecker/src/Unison/Codecs.hs +++ b/parser-typechecker/src/Unison/Codecs.hs @@ -315,7 +315,6 @@ serializeReference ref = case ref of putByteString bs putLength i putLength n - _ -> error "impossible" serializeConstructorArities :: MonadPut m => Reference -> [Int] -> m () serializeConstructorArities r constructorArities = do diff --git a/unison-core/src/Unison/Reference.hs b/unison-core/src/Unison/Reference.hs index 8bf809b5a..fb07f91ee 100644 --- a/unison-core/src/Unison/Reference.hs +++ b/unison-core/src/Unison/Reference.hs @@ -57,8 +57,7 @@ data Reference pattern Derived :: H.Hash -> Pos -> Size -> Reference pattern Derived h i n = DerivedId (Id h i n) --- A good idea, but causes a weird problem with view patterns in PatternP.hs in ghc 8.4.3 ---{-# COMPLETE Builtin, Derived #-} +{-# COMPLETE Builtin, Derived #-} -- | @Pos@ is a position into a cycle of size @Size@, as cycles are hashed together. data Id = Id H.Hash Pos Size deriving (Generic) @@ -80,7 +79,6 @@ toShortHash (Derived h i n) = SH.ShortHash (H.base32Hex h) index Nothing where -- todo: remove `n` parameter; must also update readSuffix index = Just $ showSuffix i n -toShortHash (DerivedId _) = error "this should be covered above" -- toShortHash . fromJust . fromShortHash == id and -- fromJust . fromShortHash . toShortHash == id @@ -127,11 +125,9 @@ newtype Component = Component { members :: Set Reference } -- Gives the component (dependency cycle) that the reference is a part of componentFor :: Reference -> Component -componentFor b@(Builtin _ ) = Component (Set.singleton b) -componentFor ( DerivedId (Id h _ n)) = Component - (Set.fromList - [ DerivedId (Id h i n) | i <- take (fromIntegral n) [0 ..] ] - ) +componentFor b@Builtin {} = Component (Set.singleton b) +componentFor (Derived h _ n) = + Component $ Set.fromList [Derived h i n | i <- take (fromIntegral n) [0 ..]] derivedBase32Hex :: Text -> Pos -> Size -> Reference derivedBase32Hex b32Hex i n = DerivedId (Id (fromMaybe msg h) i n) diff --git a/unison-core/src/Unison/Term.hs b/unison-core/src/Unison/Term.hs index 71526acc5..0e0df4dfe 100644 --- a/unison-core/src/Unison/Term.hs +++ b/unison-core/src/Unison/Term.hs @@ -1093,8 +1093,6 @@ instance Var v => Hashable1 (F v a p) where Or x y -> [tag 17, hashed $ hash x, hashed $ hash y] TermLink r -> [tag 18, accumulateToken r] TypeLink r -> [tag 19, accumulateToken r] - _ -> - error $ "unhandled case in hash: " <> show (void e) -- mostly boring serialization code below ...