Merge pull request #2192 from unisonweb/topic/reference-complete

`{-#COMPLETE#-}` seems to have been fixed
This commit is contained in:
Arya Irani 2021-07-09 21:48:07 -07:00 committed by GitHub
commit e8dd1d5b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 26 deletions

View File

@ -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.

View File

@ -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

View File

@ -239,7 +239,6 @@ putReference r = case r of
putHash hash
putLength i
putLength n
_ -> error "unpossible"
getReference :: MonadGet m => m Reference
getReference = do

View File

@ -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

View File

@ -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)

View File

@ -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 ...