Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] GHC 964 cabal compilation #5096

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, bytes
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/LocalIds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data LocalIds' t h = LocalIds
{ textLookup :: Vector t,
defnLookup :: Vector h
}
deriving (Show)
deriving (Functor, Show)

type LocalIds = LocalIds' TextId ObjectId

Expand Down
6 changes: 6 additions & 0 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Patch/TermEdit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ type Referent' t h = Referent.Referent' (Reference' t h) (Reference' t h)
data TermEdit' t h = Replace (Referent' t h) Typing | Deprecate
deriving (Eq, Ord, Show)

instance Functor (TermEdit' t) where
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interestingly the default deriving doesn't work:

U/Codebase/Sqlite/Patch/TermEdit.hs:23:17: error: [GHC-16437]
    • Can't make a derived instance of ‘Functor (TermEdit' t)’:
        Constructor ‘Replace’ must use the type variable only as the last argument of a data type
    • In the data declaration for ‘TermEdit'’
   |
23 |   deriving (Eq, Functor, Ord, Show)
   |                 ^^^^^^^

Copy link
Contributor

@aryairani aryairani Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but I'd guess the default Functor can only figure out one type variable?

I dunno.

fmap :: (a -> b) -> TermEdit' t a -> TermEdit' t b
fmap f (Replace (Referent.Ref termRef) typing) = Replace (Referent.Ref (fmap f termRef)) typing
fmap f (Replace (Referent.Con typeRef consId) typing) = Replace (Referent.Con (fmap f typeRef) consId) typing
fmap _ Deprecate = Deprecate

_Replace :: Prism (TermEdit' t h) (TermEdit' t' h') (Referent' t h, Typing) (Referent' t' h', Typing)
_Replace = prism embed project
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type TypeEdit = TypeEdit' Db.TextId Db.ObjectId
type HashTypeEdit = TypeEdit' Text ComponentHash

data TypeEdit' t h = Replace (Reference' t h) | Deprecate
deriving (Eq, Ord, Show)
deriving (Eq, Functor, Ord, Show)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add Functor on this? part of auto-deriving something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, if I don't add it then it errors out with:

U/Codebase/Sqlite/Patch/TypeEdit.hs:32:10: error: [GHC-39999]
     No instance for ‘Functor (TypeEdit' a)’
        arising from the head of a quantified constraint
        arising from the superclasses of an instance declaration
     In the instance declaration for ‘Bifunctor TypeEdit'’
   |
32 | instance Bifunctor TypeEdit' where
   |          ^^^^^^^^^^^^^^^^^^^


_Replace :: Prism (TypeEdit' t h) (TypeEdit' t' h') (Reference' t h) (Reference' t' h')
_Replace = prism Replace project
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase/U/Codebase/Referent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Id = Id' Hash Hash
data Id' hTm hTp
= RefId (Reference.Id' hTm)
| ConId (Reference.Id' hTp) ConstructorId
deriving (Eq, Ord, Show)
deriving (Eq, Functor, Ord, Show)

instance Bifunctor Referent' where
bimap f g = \case
Expand Down
1 change: 1 addition & 0 deletions codebase2/codebase/U/Codebase/Reflog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data Entry causal text = Entry
toRootCausalHash :: causal,
reason :: text
}
deriving (Functor)

instance Bifunctor Entry where
bimap = bimapDefault
Expand Down
2 changes: 1 addition & 1 deletion codebase2/core/U/Codebase/Reference.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ data ReferenceType = RtTerm | RtType deriving (Eq, Ord, Show)
data Reference' t h
= ReferenceBuiltin t
| ReferenceDerived (Id' h)
deriving stock (Eq, Generic, Ord, Show)
deriving stock (Eq, Generic, Functor, Ord, Show)

-- | A type declaration reference.
type TermReference' t h = Reference' t h
Expand Down
2 changes: 1 addition & 1 deletion codebase2/core/Unison/Core/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ data ProjectAndBranch a b = ProjectAndBranch
{ project :: a,
branch :: b
}
deriving stock (Eq, Generic, Show)
deriving stock (Eq, Generic, Show, Functor)

instance Bifunctor ProjectAndBranch where
bimap f g (ProjectAndBranch a b) = ProjectAndBranch (f a) (g b)
Expand Down
6 changes: 3 additions & 3 deletions codebase2/util-term/U/Util/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ flattenEffects es = [es]
generalize :: (Ord v) => [v] -> TypeR r v -> TypeR r v
generalize vs t = foldr f t vs
where
f v t = if Set.member v (ABT.freeVars t) then forall v t else t
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a warning, not strictly necessary:

U/Util/Type.hs:84:1: warning: [GHC-64088] [-Wforall-identifier]
    The use of ‘forall’ as an identifier
    will become an error in a future GHC release.
    Suggested fix:
      Consider using another name, such as
      ‘forAll’, ‘for_all’, or ‘forall_’.
   |
84 | forall v body = ABT.tm () (Forall (ABT.abs () v body))
   | ^^^^^^

Copy link
Contributor

@aryairani aryairani Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our build requires we have no warnings, so this change would require a rename at some point.

Sorry, I couldn't see on the Conversation page that you'd already renamed it.

f v t = if Set.member v (ABT.freeVars t) then forAll v t else t

-- * Patterns

Expand All @@ -80,8 +80,8 @@ pattern Effect1' e t <- ABT.Tm' (Effect e t)
pattern Ref' :: r -> TypeR r v
pattern Ref' r <- ABT.Tm' (Ref r)

forall :: (Ord v) => v -> TypeR r v -> TypeR r v
forall v body = ABT.tm () (Forall (ABT.abs () v body))
forAll :: (Ord v) => v -> TypeR r v -> TypeR r v
forAll v body = ABT.tm () (Forall (ABT.abs () v body))

unforall' :: TypeR r v -> ([v], TypeR r v)
unforall' (ForallsNamed' vs t) = (vs, t)
Expand Down
8 changes: 7 additions & 1 deletion contrib/cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages:
../fuzzyfind
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local copy of fuzzyfind as we haven't built the new packages following the update yet

codebase2/codebase
codebase2/codebase-sqlite
codebase2/codebase-sqlite-hashing-v2
Expand Down Expand Up @@ -29,6 +30,8 @@ packages:
parser-typechecker
unison-core
unison-cli
unison-cli-main
unison-merge
unison-hashing-v2
unison-share-api
unison-share-projects-api
Expand All @@ -48,7 +51,7 @@ source-repository-package
constraints:
fsnotify < 0.4,
crypton-x509-store <= 1.6.8,
servant <= 0.19.1,
servant <= 0.20.1,
optparse-applicative <= 0.17.1.0

-- For now there is no way to apply ghc-options for all local packages
Expand Down Expand Up @@ -119,6 +122,9 @@ package unison-util-rope
package parser-typechecker
ghc-options: -Wall -Werror -Wno-name-shadowing -Wno-type-defaults -Wno-missing-pattern-synonym-signatures -fprint-expanded-synonyms -fwrite-ide-info

package unison-merge
ghc-options: -Wall -Werror -Wno-name-shadowing -Wno-type-defaults -Wno-missing-pattern-synonym-signatures -fprint-expanded-synonyms -fwrite-ide-info

package unison-cli
ghc-options: -Wall -Werror -Wno-name-shadowing -Wno-type-defaults -Wno-missing-pattern-synonym-signatures -fprint-expanded-synonyms -fwrite-ide-info

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall -fno-warn-orphans
ghc-options: -Wall -Werror -fno-warn-orphans
build-depends:
base
, network-uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall -fno-warn-orphans
ghc-options: -Wall -Werror -fno-warn-orphans
build-depends:
aeson
, base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall -fno-warn-orphans
ghc-options: -Wall -Werror -fno-warn-orphans
build-depends:
base
, sqlite-simple
Expand Down
2 changes: 1 addition & 1 deletion lib/unison-hashing/unison-hashing.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ library
TypeApplications
TypeFamilies
ViewPatterns
ghc-options: -Wall -O0 -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
ghc-options: -Wall -Werror -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
build-depends:
base
, unison-hash
Expand Down
1 change: 1 addition & 0 deletions lib/unison-prelude/src/Unison/Util/Tuple.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeOperators #-}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/Unison/Util/Tuple.hs:14:13: error: [GHC-58520] [-Wtype-equality-requires-operators, Werror=type-equality-requires-operators]
    The use of ‘~’ without TypeOperators
    will become an error in a future GHC release.
    Suggested fix: Perhaps you intended to use TypeOperators
   |
14 | instance (x ~ (a, b, c)) => Drop4th (a, b, c, d) x where
   |             ^


-- | Tuple utils.
module Unison.Util.Tuple
Expand Down
1 change: 0 additions & 1 deletion lib/unison-prelude/unison-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ library
TypeApplications
TypeFamilies
ViewPatterns
ghc-options: -Wall
build-depends:
base
, bytestring
Expand Down
6 changes: 3 additions & 3 deletions lib/unison-pretty-printer/unison-pretty-printer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall -O0 -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
ghc-options: -Wall -Werror -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
build-depends:
ListLike
, ansi-terminal
Expand Down Expand Up @@ -100,7 +100,7 @@ executable prettyprintdemo
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall -O0 -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
ghc-options: -Wall -Werror -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
build-depends:
base
, safe
Expand Down Expand Up @@ -141,7 +141,7 @@ test-suite pretty-printer-tests
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall -O0 -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures -W -threaded -rtsopts "-with-rtsopts=-N -T" -v0
ghc-options: -Wall -Werror -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures -W -threaded -rtsopts "-with-rtsopts=-N -T" -v0
build-depends:
base
, code-page
Expand Down
4 changes: 2 additions & 2 deletions lib/unison-sqlite/src/Unison/Sqlite/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ execute conn@(Connection _ _ conn0) sql@(Sql s params) = do
--
-- This function does not support parameters, and is mostly useful for executing DDL and migrations.
executeStatements :: Connection -> Text -> IO ()
executeStatements conn@(Connection _ _ (Sqlite.Connection database)) sql = do
executeStatements conn@(Connection _ _ connection) sql = do
logQuery (Sql sql []) Nothing
Direct.Sqlite.exec database sql `catch` \(exception :: Sqlite.SQLError) ->
Direct.Sqlite.exec (Sqlite.connectionHandle connection) sql `catch` \(exception :: Sqlite.SQLError) ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throwSqliteQueryException
SqliteQueryExceptionInfo
{ connection = conn,
Expand Down
6 changes: 2 additions & 4 deletions lib/unison-sqlite/unison-sqlite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, direct-sqlite
Expand All @@ -74,7 +73,7 @@ library
, pretty-simple
, random
, recover-rtti
, sqlite-simple
, sqlite-simple ==0.4.18.2
, template-haskell
, text
, text-builder
Expand Down Expand Up @@ -122,7 +121,6 @@ test-suite tests
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, code-page
Expand All @@ -137,7 +135,7 @@ test-suite tests
, pretty-simple
, random
, recover-rtti
, sqlite-simple
, sqlite-simple ==0.4.18.2
, template-haskell
, text
, text-builder
Expand Down
1 change: 0 additions & 1 deletion lib/unison-util-base32hex/unison-util-base32hex.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, base32
Expand Down
2 changes: 0 additions & 2 deletions lib/unison-util-bytes/unison-util-bytes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ library
TypeApplications
TypeFamilies
ViewPatterns
ghc-options: -Wall
build-depends:
base
, basement
Expand Down Expand Up @@ -102,7 +101,6 @@ test-suite util-bytes-tests
TypeApplications
TypeFamilies
ViewPatterns
ghc-options: -Wall
build-depends:
base
, basement
Expand Down
2 changes: 0 additions & 2 deletions lib/unison-util-cache/unison-util-cache.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ library
TypeApplications
TypeFamilies
ViewPatterns
ghc-options: -Wall
build-depends:
base
, containers
Expand Down Expand Up @@ -92,7 +91,6 @@ test-suite util-cache-tests
TypeApplications
TypeFamilies
ViewPatterns
ghc-options: -Wall
build-depends:
async
, base
Expand Down
1 change: 0 additions & 1 deletion lib/unison-util-file-embed/unison-util-file-embed.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, file-embed
Expand Down
2 changes: 1 addition & 1 deletion lib/unison-util-nametree/src/Unison/Util/Defns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ data Defns terms types = Defns
{ terms :: terms,
types :: types
}
deriving stock (Generic, Show)
deriving stock (Generic, Functor, Show)
deriving (Monoid, Semigroup) via GenericSemigroupMonoid (Defns terms types)

instance Bifoldable Defns where
Expand Down
1 change: 0 additions & 1 deletion lib/unison-util-nametree/unison-util-nametree.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, containers
Expand Down
3 changes: 0 additions & 3 deletions lib/unison-util-relation/unison-util-relation.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ library
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, containers
Expand Down Expand Up @@ -70,7 +69,6 @@ test-suite util-relation-tests
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, code-page
Expand Down Expand Up @@ -105,7 +103,6 @@ benchmark relation
TupleSections
TypeApplications
ViewPatterns
ghc-options: -Wall
build-depends:
base
, code-page
Expand Down
2 changes: 1 addition & 1 deletion parser-typechecker/src/Unison/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ refPromiseBuiltins =
forall1 :: Text -> (Type -> Type) -> Type
forall1 name body =
let a = Var.named name
in Type.forall () a (body $ Type.var () a)
in Type.forAll () a (body $ Type.var () a)

forall2 ::
Text -> Text -> (Type -> Type -> Type) -> Type
Expand Down
2 changes: 1 addition & 1 deletion parser-typechecker/src/Unison/Builtin/Decls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ builtinEffectDecls =
Structural
()
[]
[ ((), v "Exception.raise", Type.forall () (v "x") (failureType () `arr` self (var "x")))
[ ((), v "Exception.raise", Type.forAll () (v "x") (failureType () `arr` self (var "x")))
]

pattern UnitRef :: Reference
Expand Down
3 changes: 2 additions & 1 deletion parser-typechecker/src/Unison/Codebase/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
module Unison.Codebase.Execute where

import Control.Exception (finally)
import Control.Monad.Except
import Control.Monad.Except (throwError, runExceptT)
import Control.Monad.IO.Class (liftIO)
import Unison.Codebase qualified as Codebase
import Unison.Codebase.Branch qualified as Branch
import Unison.Codebase.Branch.Names qualified as Branch
Expand Down
2 changes: 1 addition & 1 deletion parser-typechecker/src/Unison/Codebase/MainTerm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ getMainTerm loadTypeOfTerm parseNames mainName mainType = do
builtinMain :: (Var v) => a -> Type.Type v a
builtinMain a =
let result = Var.named "result"
in Type.forall a result (builtinMainWithResultType a (Type.var a result))
in Type.forAll a result (builtinMainWithResultType a (Type.var a result))

-- '{io2.IO, Exception} res
builtinMainWithResultType :: (Var v) => a -> Type.Type v a -> Type.Type v a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Unison.Codebase.SqliteCodebase.Migrations.MigrateSchema6To7 (migrateSchema6To7) where

import Control.Monad.Except
import Control.Monad.State
import U.Codebase.Branch.Type (NamespaceStats)
import U.Codebase.Sqlite.DbId qualified as DB
Expand Down
Loading
Loading