Skip to content

Commit

Permalink
Trivial fixes
Browse files Browse the repository at this point in the history
* trivial additions of functor
* limit imports to just used functions
* remove unnecesary imports
  • Loading branch information
neduard committed Jun 25, 2024
1 parent f74565d commit d745d24
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 20 deletions.
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
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)

_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
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
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
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
3 changes: 2 additions & 1 deletion parser-typechecker/src/Unison/KindInference/Solve/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Unison.KindInference.Solve.Monad
where

import Control.Lens (Lens', (%%~))
import Control.Monad.Fix (MonadFix (..))
import Control.Monad.Reader qualified as M
import Control.Monad.State.Strict qualified as M
import Data.Functor.Identity
Expand Down Expand Up @@ -64,7 +65,7 @@ newtype Solve v loc a = Solve {unSolve :: Env -> SolveState v loc -> (a, SolveSt
( Functor,
Applicative,
Monad,
M.MonadFix,
MonadFix,
M.MonadReader Env,
M.MonadState (SolveState v loc)
)
Expand Down
1 change: 0 additions & 1 deletion unison-cli/src/Unison/LSP/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Unison.LSP.CodeLens where

import Control.Lens hiding (List)
import Control.Monad.Except
import Data.Aeson qualified as Aeson
import Data.Map qualified as Map
import Data.Text qualified as Text
Expand Down
5 changes: 4 additions & 1 deletion unison-cli/src/Unison/LSP/UCMWorker.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module Unison.LSP.UCMWorker where

import Control.Monad.Reader
import Control.Monad (guard)
import Control.Monad.State (liftIO)
import Control.Monad.Reader.Class (ask)
import Data.Functor (void)
import U.Codebase.HashTags
import Unison.Codebase qualified as Codebase
import Unison.Codebase.Branch qualified as Branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

module Unison.Server.Local.Endpoints.Current where

import Control.Monad.Except
import Data.Aeson
import Data.OpenApi (ToSchema (..))
import Servant ((:>))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Unison.Server.Local.Endpoints.FuzzyFind where

import Control.Monad.Except
import Data.Aeson
import Data.OpenApi (ToSchema)
import Servant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Unison.Server.Local.Endpoints.NamespaceDetails where

import Control.Monad.Except
import Data.Set qualified as Set
import Servant (Capture, QueryParam, (:>))
import Servant.Docs (DocCapture (..), ToCapture (..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Unison.Server.Local.Endpoints.NamespaceListing (serve, NamespaceListingAPI, NamespaceListing (..), NamespaceObject (..), NamedNamespace (..), NamedPatch (..), KindExpression (..)) where

import Control.Monad.Except
import Data.Aeson
import Data.OpenApi (ToSchema)
import Servant
Expand Down
2 changes: 1 addition & 1 deletion unison-share-api/src/Unison/Server/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ data ExactName name ref = ExactName
{ name :: name,
ref :: ref
}
deriving stock (Show, Eq, Ord)
deriving stock (Show, Eq, Functor, Ord)

instance ToParamSchema (ExactName Name ShortHash) where
toParamSchema _ =
Expand Down
8 changes: 4 additions & 4 deletions unison-share-api/src/Unison/Sync/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ entityDependencies = \case
C Causal {namespaceHash, parents} -> Set.insert namespaceHash parents

data TermComponent text hash = TermComponent [(LocalIds text hash, ByteString)]
deriving stock (Show, Eq, Ord)
deriving stock (Show, Eq, Functor, Ord)

instance Bifoldable TermComponent where
bifoldMap = bifoldMapDefault
Expand Down Expand Up @@ -252,7 +252,7 @@ decodeComponentPiece = Aeson.withObject "Component Piece" \obj -> do
pure (localIDs, bytes)

data DeclComponent text hash = DeclComponent [(LocalIds text hash, ByteString)]
deriving stock (Show, Eq, Ord)
deriving stock (Show, Eq, Functor, Ord)

instance Bifoldable DeclComponent where
bifoldMap = bifoldMapDefault
Expand Down Expand Up @@ -280,7 +280,7 @@ data LocalIds text hash = LocalIds
{ texts :: [text],
hashes :: [hash]
}
deriving stock (Show, Eq, Ord)
deriving stock (Show, Eq, Functor, Ord)

instance Bifoldable LocalIds where
bifoldMap = bifoldMapDefault
Expand Down Expand Up @@ -381,7 +381,7 @@ data Namespace text hash = Namespace
childLookup :: [(hash, hash)], -- (namespace hash, causal hash)
bytes :: LocalBranchBytes
}
deriving stock (Eq, Ord, Show)
deriving stock (Eq, Functor, Ord, Show)

instance Bifoldable Namespace where
bifoldMap = bifoldMapDefault
Expand Down

0 comments on commit d745d24

Please sign in to comment.