mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-04 00:36:58 +03:00
Delete DA.Prelude (#914)
* Use DA.Prelude a lot less * Make LANGUAGE pragmas have the right case * Don't reexport DA.Prelude * Remove more DA.Prelude imports * Remove the nastiest renaming DA.Prelude * Final removal of DA.Prelude * Kill DA.Prelude * Add missing dependencies * More missing package imports * More missing package imports * Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs * Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs
This commit is contained in:
parent
f098b0e4be
commit
fe3e5c9639
@ -11,12 +11,14 @@ da_haskell_library(
|
||||
"containers",
|
||||
"deepseq",
|
||||
"extra",
|
||||
"hashable",
|
||||
"lens",
|
||||
"mtl",
|
||||
"recursion-schemes",
|
||||
"safe",
|
||||
"scientific",
|
||||
"tagged",
|
||||
"template-haskell",
|
||||
"text",
|
||||
"time",
|
||||
"unordered-containers",
|
||||
|
@ -12,13 +12,19 @@ module DA.Daml.LF.Ast.Base(
|
||||
module DA.Daml.LF.Ast.Base
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Data.Hashable
|
||||
import Data.Data
|
||||
import Data.Tagged
|
||||
import GHC.Generics(Generic)
|
||||
import Data.Int
|
||||
import Control.DeepSeq
|
||||
import Control.Lens
|
||||
import qualified Data.NameMap as NM
|
||||
import qualified Data.Text as T
|
||||
import Data.Fixed
|
||||
import qualified "template-haskell" Language.Haskell.TH as TH
|
||||
import qualified Control.Lens.TH as Lens.TH
|
||||
import Orphans.Lib_hashable ()
|
||||
|
||||
import DA.Daml.LF.Ast.Version
|
||||
|
||||
@ -789,7 +795,23 @@ instance NM.Named Module where
|
||||
type Name Module = ModuleName
|
||||
name = moduleName
|
||||
|
||||
concatSequenceA
|
||||
fmap concat $ sequenceA $
|
||||
let
|
||||
-- | Generate a lens for every field in a record. The name of the lens is the
|
||||
-- name of the field prefixed by an underscore. For instance, for
|
||||
--
|
||||
-- > data Foo = Foo{bar :: Int, _baz :: Bool}
|
||||
--
|
||||
-- it will generate
|
||||
--
|
||||
-- > _bar :: Lens' Foo Int
|
||||
-- > __baz :: Lens' Foo Bool
|
||||
makeUnderscoreLenses :: TH.Name -> TH.DecsQ
|
||||
makeUnderscoreLenses =
|
||||
Lens.TH.makeLensesWith (set Lens.TH.lensField noUnderscoreNoPrefixNamer Lens.TH.lensRules)
|
||||
where
|
||||
noUnderscoreNoPrefixNamer _ _ n = [Lens.TH.TopName (TH.mkName ('_':TH.nameBase n))]
|
||||
in
|
||||
[ makePrisms ''Kind
|
||||
, makePrisms ''Type
|
||||
, makePrisms ''Expr
|
||||
|
@ -16,8 +16,7 @@ module DA.Daml.LF.Ast.Optics(
|
||||
templateExpr
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Data.Tagged
|
||||
import Control.Lens
|
||||
import Control.Lens.Ast
|
||||
import Control.Lens.MonoTraversal
|
||||
|
@ -12,11 +12,11 @@ module DA.Daml.LF.Ast.Pretty(
|
||||
(<:>)
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import qualified Data.Ratio as Ratio
|
||||
import Control.Lens
|
||||
import Control.Lens.Ast (rightSpine)
|
||||
import Data.Tagged
|
||||
import Data.Maybe
|
||||
import qualified Data.NameMap as NM
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Time.Clock.POSIX as Clock.Posix
|
||||
|
@ -8,13 +8,13 @@ module DA.Daml.LF.Ast.Type
|
||||
, substitute
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Data.Bifunctor
|
||||
import Data.Functor.Foldable (cata)
|
||||
import qualified Data.Map.Strict as Map
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.Text as T
|
||||
import Data.Tagged
|
||||
import Data.List
|
||||
import Safe (findJust)
|
||||
import Safe.Exact (zipWithExactMay)
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module DA.Daml.LF.Ast.Util(module DA.Daml.LF.Ast.Util) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Data.Tagged
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
import Control.Lens.Ast
|
||||
import qualified Data.Graph as G
|
||||
|
@ -5,7 +5,8 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module DA.Daml.LF.Ast.Version(module DA.Daml.LF.Ast.Version) where
|
||||
|
||||
import DA.Prelude
|
||||
import Data.Data
|
||||
import GHC.Generics
|
||||
import DA.Pretty
|
||||
import Control.DeepSeq
|
||||
import qualified Data.Text as T
|
||||
|
@ -33,8 +33,8 @@ import Control.Lens (Iso', Prism', from, iso, prism')
|
||||
import Control.DeepSeq (NFData(..))
|
||||
|
||||
import qualified Data.Scientific as Scientific
|
||||
|
||||
import DA.Prelude
|
||||
import GHC.Generics(Generic)
|
||||
import Text.Read
|
||||
import Data.Ratio((%))
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ decimalToScientific =
|
||||
|
||||
stringToScientific :: Prism' String Scientific.Scientific
|
||||
stringToScientific =
|
||||
prism' (Scientific.formatScientific Scientific.Fixed Nothing) readMay
|
||||
prism' (Scientific.formatScientific Scientific.Fixed Nothing) readMaybe
|
||||
|
||||
|
||||
-- | Converts a `Decimal` to an `Integer` by truncating towards 0.
|
||||
@ -154,4 +154,3 @@ fromIntegerD n = Decimal n 0
|
||||
|
||||
stringToDecimal :: Prism' String Decimal
|
||||
stringToDecimal = stringToScientific . from decimalToScientific
|
||||
|
||||
|
@ -16,6 +16,7 @@ da_haskell_library(
|
||||
"memory",
|
||||
"proto3-suite",
|
||||
"scientific",
|
||||
"tagged",
|
||||
"template-haskell",
|
||||
"text",
|
||||
"vector",
|
||||
|
@ -14,7 +14,9 @@ module DA.Daml.LF.Proto3.Archive
|
||||
import Control.Lens (over, _Left)
|
||||
import qualified "cryptonite" Crypto.Hash as Crypto
|
||||
import qualified Da.DamlLf as ProtoLF
|
||||
import DA.Prelude
|
||||
import Data.Tagged
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
import DA.Pretty
|
||||
import qualified DA.Daml.LF.Ast as LF
|
||||
import qualified DA.Daml.LF.Proto3.Decode as Decode
|
||||
|
@ -2,7 +2,6 @@
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE MultiWayIf #-}
|
||||
|
||||
module DA.Daml.LF.Proto3.DecodeV1
|
||||
@ -12,8 +11,10 @@ module DA.Daml.LF.Proto3.DecodeV1
|
||||
|
||||
import DA.Daml.LF.Ast as LF
|
||||
import DA.Daml.LF.Proto3.Error
|
||||
import DA.Prelude
|
||||
import Data.List (foldl)
|
||||
import Data.Tagged
|
||||
import Control.Monad
|
||||
import Text.Read
|
||||
import Data.List
|
||||
import DA.Daml.LF.Mangling
|
||||
import qualified Da.DamlLf1 as LF1
|
||||
import Data.Either.Combinators (mapLeft)
|
||||
@ -439,7 +440,7 @@ decodeVarWithType LF1.VarWithType{..} =
|
||||
decodePrimLit :: LF1.PrimLit -> Decode BuiltinExpr
|
||||
decodePrimLit (LF1.PrimLit mbSum) = mayDecode "primLitSum" mbSum $ \case
|
||||
LF1.PrimLitSumInt64 sInt -> pure $ BEInt64 sInt
|
||||
LF1.PrimLitSumDecimal sDec -> case readMay (TL.unpack sDec) of
|
||||
LF1.PrimLitSumDecimal sDec -> case readMaybe (TL.unpack sDec) of
|
||||
Nothing -> Left $ ParseError ("bad fixed while decoding Decimal: '" <> TL.unpack sDec <> "'")
|
||||
Just dec -> return (BEDecimal dec)
|
||||
LF1.PrimLitSumTimestamp sTime -> pure $ BETimestamp sTime
|
||||
|
@ -21,8 +21,9 @@ import qualified Data.Vector as V
|
||||
import qualified Data.Scientific as Scientific
|
||||
import GHC.Stack (HasCallStack)
|
||||
|
||||
import DA.Prelude
|
||||
import DA.Pretty
|
||||
import Data.Tagged
|
||||
import Control.Monad
|
||||
import qualified DA.Daml.LF.Decimal as Decimal
|
||||
import DA.Daml.LF.Ast
|
||||
import DA.Daml.LF.Mangling
|
||||
|
@ -11,6 +11,7 @@ da_haskell_library(
|
||||
"containers",
|
||||
"either",
|
||||
"extra",
|
||||
"hashable",
|
||||
"lens",
|
||||
"mtl",
|
||||
"recursion-schemes",
|
||||
|
@ -8,8 +8,7 @@ module DA.Daml.LF.TypeChecker
|
||||
, errorLocation
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Data.Functor
|
||||
import Data.Either.Combinators (mapLeft)
|
||||
import Data.Foldable
|
||||
|
||||
|
@ -32,8 +32,8 @@ module DA.Daml.LF.TypeChecker.Check(
|
||||
checkModule
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Data.Hashable
|
||||
import Data.Tagged
|
||||
import Control.Lens hiding (Context)
|
||||
import Control.Monad.Extra
|
||||
import Data.Foldable
|
||||
|
@ -18,11 +18,10 @@ module DA.Daml.LF.TypeChecker.PartyLiterals
|
||||
( checkModule
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Foldable (for_)
|
||||
import Data.List.Extra (nubOrd)
|
||||
import Data.List.Extra
|
||||
|
||||
import DA.Daml.LF.Ast
|
||||
import DA.Daml.LF.Ast.Optics (exprPartyLiteral, exprValueRef, templateExpr)
|
||||
|
@ -17,10 +17,9 @@ module DA.Daml.LF.TypeChecker.Serializability
|
||||
, checkModule
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Control.Lens (matching, toListOf)
|
||||
import Control.Monad.Extra (mconcatMapM)
|
||||
import Control.Monad.Extra
|
||||
import Data.List
|
||||
import Data.Either (isRight)
|
||||
import Data.Foldable (for_)
|
||||
import qualified Data.HashSet as HS
|
||||
|
@ -1,7 +1,6 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
-- | Pretty-printing of scenario results
|
||||
@ -15,15 +14,19 @@ module DA.Daml.LF.PrettyScenario
|
||||
) where
|
||||
|
||||
import Control.Lens (preview, review)
|
||||
import Control.Monad ((>=>))
|
||||
import Control.Monad.Reader (Reader, asks, runReader)
|
||||
import Control.Monad.Trans.Except (ExceptT (..), runExceptT, throwE)
|
||||
import Control.Monad
|
||||
import Control.Monad.Reader
|
||||
import Control.Monad.Trans.Except
|
||||
import DA.Daml.LF.Decimal (stringToDecimal)
|
||||
import qualified DA.Daml.LF.Ast as LF
|
||||
import DA.Prelude
|
||||
import Data.Tagged
|
||||
import Control.Applicative
|
||||
import Text.Read hiding (parens)
|
||||
import DA.Pretty as Pretty
|
||||
import Data.Either.Extra (eitherToMaybe)
|
||||
import Data.Int (Int32)
|
||||
import Data.Either.Extra
|
||||
import Data.Int
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import qualified Data.NameMap as NM
|
||||
import qualified Data.Map.Strict as MS
|
||||
import qualified Data.Ratio as Ratio
|
||||
@ -94,7 +97,7 @@ lookupModuleFromQualifiedName world mbPkgId qualName = do
|
||||
|
||||
parseNodeId :: NodeId -> [Integer]
|
||||
parseNodeId =
|
||||
fmap (fromMaybe 0 . readMay . TL.unpack)
|
||||
fmap (fromMaybe 0 . readMaybe . TL.unpack)
|
||||
. TL.splitOn ":"
|
||||
. nodeIdId
|
||||
|
||||
|
@ -26,14 +26,15 @@ module DA.Daml.LF.ScenarioServiceClient.LowLevel
|
||||
, ScenarioServiceException(..)
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Conduit (runConduit, (.|))
|
||||
import GHC.Generics
|
||||
import Text.Read
|
||||
import Data.Tagged
|
||||
import Control.Concurrent.Async
|
||||
import Control.Concurrent.MVar
|
||||
import Control.DeepSeq
|
||||
import Control.Exception
|
||||
import Control.Monad (void)
|
||||
import Control.Monad
|
||||
import Control.Monad.Managed
|
||||
import qualified DA.Daml.LF.Proto3.EncodeV1 as EncodeV1
|
||||
import qualified Data.ByteString as BS
|
||||
@ -163,7 +164,7 @@ start opts@Options{..} = do
|
||||
liftIO (putMVar portMVar (Left "Stdout of scenario service terminated before we got the PORT=<port> message"))
|
||||
Just (T.unpack -> line) ->
|
||||
case splitOn "=" line of
|
||||
["PORT", ps] | Just p <- readMay ps ->
|
||||
["PORT", ps] | Just p <- readMaybe ps ->
|
||||
liftIO (putMVar portMVar (Right p)) >> C.awaitForever printStdout
|
||||
_ -> do
|
||||
liftIO (optLogError ("Expected PORT=<port> from scenario service, but got '" <> line <> "'. Ignoring it."))
|
||||
|
@ -13,7 +13,7 @@ module DA.Daml.GHC.Compiler.Primitives(convertPrim) where
|
||||
import DA.Daml.GHC.Compiler.UtilLF
|
||||
import DA.Daml.LF.Ast
|
||||
import DA.Pretty (renderPretty)
|
||||
import DA.Prelude (Tagged(..))
|
||||
import Data.Tagged
|
||||
import qualified Data.Text as T
|
||||
|
||||
convertPrim :: Version -> String -> Type -> Expr
|
||||
|
@ -16,8 +16,7 @@ import qualified Data.Aeson.Encode.Pretty as AP
|
||||
import Data.Algorithm.Diff (getGroupedDiff)
|
||||
import Data.Algorithm.DiffOutput (ppDiff)
|
||||
import qualified Data.ByteString.Lazy.Char8 as BS
|
||||
import Data.List (sort)
|
||||
import Data.List.Extra (nubOrd)
|
||||
import Data.List.Extra
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Extended as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
@ -26,8 +25,7 @@ import System.FilePath
|
||||
import System.IO.Extra
|
||||
import qualified Test.Tasty.Extended as Tasty
|
||||
import Test.Tasty.HUnit.Extended
|
||||
|
||||
import DA.Prelude
|
||||
import Data.Maybe
|
||||
|
||||
|
||||
testDir :: FilePath
|
||||
|
@ -30,8 +30,6 @@ module DA.Service.Daml.Compiler.Impl.Handle
|
||||
, getBaseDir
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
-- HS/DAML to LF compiler (daml-ghc)
|
||||
import DA.Daml.GHC.Compiler.Convert (sourceLocToRange)
|
||||
import DA.Daml.GHC.Compiler.Options
|
||||
@ -54,6 +52,10 @@ import qualified Data.Map.Strict as Map
|
||||
import qualified Data.NameMap as NM
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.Text as T
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Data.Tagged
|
||||
import Safe
|
||||
|
||||
import Data.Time.Clock
|
||||
import Data.Traversable (for)
|
||||
@ -116,7 +118,7 @@ uriToVirtualResource uri = do
|
||||
file <- Map.lookup "file" decoded
|
||||
topLevelDecl <- Map.lookup "top-level-decl" decoded
|
||||
pure $ VRScenario file (T.pack topLevelDecl)
|
||||
_ -> empty
|
||||
_ -> Nothing
|
||||
|
||||
where
|
||||
queryString :: URI.URI -> Map.Map String String
|
||||
|
@ -1,7 +1,6 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
@ -18,7 +17,11 @@ import qualified Control.Monad.Managed as Managed
|
||||
import DA.LanguageServer.Protocol
|
||||
import DA.LanguageServer.Server
|
||||
|
||||
import DA.Prelude
|
||||
import Data.Tagged
|
||||
import Control.Monad
|
||||
import Data.List.Extra
|
||||
import Control.Monad.IO.Class
|
||||
import Safe
|
||||
import qualified DA.Daml.LF.Ast as LF
|
||||
import qualified DA.Service.Daml.Compiler.Impl.Handle as Compiler
|
||||
import qualified DA.Service.Daml.LanguageServer.CodeLens as LS.CodeLens
|
||||
|
@ -1,7 +1,6 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
-- | Gather code lenses like scenario execution for a DAML file.
|
||||
@ -11,7 +10,7 @@ module DA.Service.Daml.LanguageServer.CodeLens
|
||||
|
||||
import DA.LanguageServer.Protocol
|
||||
|
||||
import DA.Prelude
|
||||
import Data.Maybe
|
||||
import qualified DA.Service.Daml.Compiler.Impl.Handle as Compiler
|
||||
import DA.Service.Daml.LanguageServer.Common
|
||||
import qualified DA.Service.Logger as Logger
|
||||
|
@ -1,7 +1,6 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
-- | Defaults and conversions between Ast types and protocol types
|
||||
@ -28,7 +27,7 @@ module DA.Service.Daml.LanguageServer.Common
|
||||
|
||||
import DA.LanguageServer.Protocol
|
||||
|
||||
import DA.Prelude
|
||||
import Data.Tagged
|
||||
import qualified DA.Pretty as Pretty
|
||||
|
||||
import qualified Data.Aeson as Aeson
|
||||
|
@ -36,6 +36,7 @@ da_haskell_library(
|
||||
"safe-exceptions",
|
||||
"shake",
|
||||
"split",
|
||||
"tagged",
|
||||
"tasty-ant-xml",
|
||||
"tasty-hunit",
|
||||
"tasty",
|
||||
|
@ -1,7 +1,6 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE ApplicativeDo #-}
|
||||
@ -12,7 +11,10 @@ module DA.Cli.Damlc (main) where
|
||||
import Control.Monad.Except
|
||||
import qualified Control.Monad.Managed as Managed
|
||||
import DA.Cli.Damlc.Base
|
||||
import Control.Exception (throwIO)
|
||||
import Data.List
|
||||
import Data.Tagged
|
||||
import Data.Maybe
|
||||
import Control.Exception
|
||||
import qualified "cryptonite" Crypto.Hash as Crypto
|
||||
import Codec.Archive.Zip
|
||||
import qualified Da.DamlLf as PLF
|
||||
@ -48,12 +50,12 @@ import qualified Network.Socket as NS
|
||||
import Options.Applicative
|
||||
import qualified Proto3.Suite as PS
|
||||
import qualified Proto3.Suite.JSONPB as Proto.JSONPB
|
||||
import System.Directory (createDirectoryIfMissing)
|
||||
import System.Environment (withProgName)
|
||||
import System.Exit (exitFailure)
|
||||
import System.FilePath (takeDirectory, (<.>), (</>), isExtensionOf, takeFileName, dropExtension, takeBaseName)
|
||||
import System.Directory
|
||||
import System.Environment
|
||||
import System.Exit
|
||||
import System.FilePath
|
||||
import System.Process(callCommand)
|
||||
import System.IO (stderr, hPutStrLn)
|
||||
import System.IO
|
||||
import qualified Text.PrettyPrint.ANSI.Leijen as PP
|
||||
import DA.Cli.Damlc.Test
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
module DA.Cli.Damlc.Base
|
||||
( module DA.Cli.Options
|
||||
, module DA.Cli.Output
|
||||
, module DA.Prelude
|
||||
, CommandM
|
||||
, Command
|
||||
, getLogger
|
||||
@ -12,7 +11,6 @@ module DA.Cli.Damlc.Base
|
||||
where
|
||||
import DA.Cli.Options
|
||||
import DA.Cli.Output
|
||||
import DA.Prelude
|
||||
import DA.Service.Daml.Compiler.Impl.Handle as Compiler
|
||||
import qualified Data.Text as T
|
||||
import qualified DA.Service.Logger as Logger
|
||||
|
@ -9,8 +9,8 @@ import DA.Cli.Damlc.Base(Command)
|
||||
import DA.Cli.Options
|
||||
import DA.Daml.GHC.Damldoc.Driver
|
||||
|
||||
import DA.Prelude
|
||||
import Options.Applicative
|
||||
import Data.Maybe
|
||||
|
||||
------------------------------------------------------------
|
||||
|
||||
|
@ -13,6 +13,8 @@ import Control.Monad.Except
|
||||
import qualified Control.Monad.Managed as Managed
|
||||
import qualified DA.Pretty
|
||||
import DA.Cli.Damlc.Base
|
||||
import Data.Maybe
|
||||
import Data.List.Extra
|
||||
import Data.Tuple.Extra
|
||||
import Control.Monad.Extra
|
||||
import DA.Service.Daml.Compiler.Impl.Handle as Compiler
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
{-# Language ApplicativeDo #-}
|
||||
{-# LANGUAGE ApplicativeDo #-}
|
||||
module DA.Cli.Options
|
||||
( module DA.Cli.Options
|
||||
) where
|
||||
@ -8,8 +8,8 @@ module DA.Cli.Options
|
||||
import qualified Data.Text as T
|
||||
import Data.List.Extra (trim, splitOn)
|
||||
import Options.Applicative
|
||||
|
||||
import DA.Prelude
|
||||
import Data.List
|
||||
import Text.Read
|
||||
import qualified DA.Pretty as Pretty
|
||||
import qualified DA.Daml.LF.Ast.Version as LF
|
||||
|
||||
@ -212,7 +212,7 @@ portOpt defaultValue = option (str >>= parse) $
|
||||
<> long "port"
|
||||
<> value defaultValue
|
||||
where
|
||||
parse cs = case readMay cs of
|
||||
parse cs = case readMaybe cs of
|
||||
Just p -> return p
|
||||
Nothing -> readerError $ "Invalid port '" <> cs <> "'."
|
||||
|
||||
@ -230,7 +230,7 @@ ekgPortOpt = option (str >>= parse) $
|
||||
<> value Nothing
|
||||
<> long "ekg"
|
||||
where
|
||||
parse cs = case readMay cs of
|
||||
parse cs = case readMaybe cs of
|
||||
Nothing -> readerError $ "Invalid port '" <> cs <> "'."
|
||||
p -> pure p
|
||||
|
||||
|
@ -1,178 +0,0 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
-- | Custom Prelude without partial functions and a more extensive default
|
||||
-- export list.
|
||||
module DA.Prelude
|
||||
(
|
||||
-- * Prelude without partial functions
|
||||
module Prelude
|
||||
|
||||
-- ** Total variants of partial functions
|
||||
|
||||
-- TODO (SM): switch to 'located-base' for the 'xxxNote' versions
|
||||
, atMay , atDef , atNote
|
||||
, tailMay , tailDef , tailNote
|
||||
, initMay , initDef , initNote
|
||||
, headMay , headDef , headNote
|
||||
, lastMay , lastDef , lastNote
|
||||
, minimumMay , minimumDef , minimumNote
|
||||
, maximumMay , maximumDef , maximumNote
|
||||
, minimumByMay , minimumByDef , minimumByNote
|
||||
, maximumByMay , maximumByDef , maximumByNote
|
||||
, foldr1May , foldr1Def , foldr1Note
|
||||
, foldl1May' , foldl1Def' , foldl1Note'
|
||||
, scanl1May , scanl1Def , scanl1Note
|
||||
, scanr1May , scanr1Def , scanr1Note
|
||||
, assertNote
|
||||
, readMay , readDef , readNote
|
||||
, fromJustDef , fromJustNote
|
||||
|
||||
-- * Common exports from Control.*
|
||||
, module Control.Applicative
|
||||
, module Control.Monad
|
||||
, liftIO
|
||||
|
||||
-- * Common exports from Data.*
|
||||
, module Data.Char
|
||||
, module Data.Function
|
||||
, module Data.Int
|
||||
, module Data.List
|
||||
, module Data.List.Extra
|
||||
, module Data.Maybe
|
||||
, module Data.Ord
|
||||
, module Data.Proxy
|
||||
, module Data.Tuple
|
||||
, module Data.Void
|
||||
, module Data.Word
|
||||
|
||||
, partitionEithers
|
||||
, singleton
|
||||
|
||||
, Data
|
||||
, Typeable
|
||||
, Hashable
|
||||
|
||||
-- ** Tagged values
|
||||
, Tagged(Tagged, unTagged)
|
||||
, retag
|
||||
, untag
|
||||
|
||||
-- ** GHC Generics support
|
||||
, Generic
|
||||
|
||||
, concatSequenceA
|
||||
, makeUnderscoreLenses
|
||||
) where
|
||||
|
||||
|
||||
|
||||
|
||||
-- orphan instances (all of them must be brought into scope here)
|
||||
-----------------------------------------------------------------
|
||||
|
||||
import Orphans.Lib_hashable ()
|
||||
|
||||
|
||||
-- normal imports
|
||||
-----------------
|
||||
|
||||
import Control.Applicative
|
||||
import Control.Exception
|
||||
import Control.Lens (set)
|
||||
import Control.Monad
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
|
||||
import Data.Char
|
||||
import Data.Data (Data)
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Either (partitionEithers)
|
||||
|
||||
import Data.Function
|
||||
import Data.Int
|
||||
import Data.Hashable (Hashable)
|
||||
import Data.List hiding
|
||||
(
|
||||
-- hide partial functions
|
||||
minimumBy
|
||||
, maximumBy
|
||||
, foldl1
|
||||
, foldl1'
|
||||
|
||||
-- foldl and nub are almost always the wrong choice performance-wise.
|
||||
, foldl
|
||||
, nub
|
||||
)
|
||||
import Data.List.Extra (nubOrd)
|
||||
import Data.Maybe
|
||||
|
||||
|
||||
import Data.Ord
|
||||
import Data.Proxy
|
||||
import Data.Tagged (Tagged(Tagged, unTagged), retag, untag)
|
||||
import Data.Tuple
|
||||
import Data.Void
|
||||
import Data.Word
|
||||
|
||||
import GHC.Generics (Generic)
|
||||
|
||||
import Prelude hiding
|
||||
(
|
||||
-- hide partial functions
|
||||
tail
|
||||
, init
|
||||
, head
|
||||
, last
|
||||
, minimum
|
||||
, maximum
|
||||
, foldr1
|
||||
, scanl1
|
||||
, scanr1
|
||||
, read
|
||||
|
||||
-- foldl is almost always the wrong choice performance-wise.
|
||||
, foldl
|
||||
)
|
||||
|
||||
-- Total variants of partial functions. See above for the collection.
|
||||
import Safe
|
||||
|
||||
|
||||
-- qualified imports
|
||||
--------------------
|
||||
|
||||
import qualified "template-haskell" Language.Haskell.TH as TH
|
||||
import qualified Control.Lens.TH as Lens.TH
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Support for fewer TH splices (speeds up GHCJS compilation)
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
-- | This function is mainly intended to be used to combine many TH-splices
|
||||
-- into a single one, as we pay a per-splice cost of starting a node-js
|
||||
-- executable and loading all libraries when compiling TH with GHCJS.
|
||||
concatSequenceA :: (Applicative f) => [f [a]] -> f [a]
|
||||
concatSequenceA = fmap concat . sequenceA
|
||||
|
||||
|
||||
-- | Alternative name for 'pure' to make the intention of creating a singleton
|
||||
-- container clearer at call sites. It can be used to create, e.g., singleton
|
||||
-- lists or singleton 'Data.NonEmpty.NonEmpty' lists.
|
||||
singleton :: Applicative f => a -> f a
|
||||
singleton = pure
|
||||
|
||||
-- | Generate a lens for every field in a record. The name of the lens is the
|
||||
-- name of the field prefixed by an underscore. For instance, for
|
||||
--
|
||||
-- > data Foo = Foo{bar :: Int, _baz :: Bool}
|
||||
--
|
||||
-- it will generate
|
||||
--
|
||||
-- > _bar :: Lens' Foo Int
|
||||
-- > __baz :: Lens' Foo Bool
|
||||
makeUnderscoreLenses :: TH.Name -> TH.DecsQ
|
||||
makeUnderscoreLenses =
|
||||
Lens.TH.makeLensesWith (set Lens.TH.lensField noUnderscoreNoPrefixNamer Lens.TH.lensRules)
|
||||
where
|
||||
noUnderscoreNoPrefixNamer _ _ n = [Lens.TH.TopName (TH.mkName ('_':TH.nameBase n))]
|
@ -22,13 +22,15 @@ module DA.Service.Logger
|
||||
, liftHandle
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
import Control.Monad.Base
|
||||
import Control.Monad.Trans.Control
|
||||
import qualified Data.Aeson as Aeson
|
||||
import qualified Data.Text as T
|
||||
import GHC.Stack
|
||||
import Data.Data
|
||||
import GHC.Generics
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Types
|
||||
|
@ -1,11 +1,11 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# Language OverloadedStrings #-}
|
||||
{-# Language DataKinds #-}
|
||||
{-# Language MultiWayIf #-}
|
||||
{-# Language BlockArguments #-}
|
||||
{-# Language GADTs #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE MultiWayIf #-}
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-|
|
||||
This uses the Google Cloud Platform (GCP) Stackdriver logging service to store
|
||||
log information. It builds up a queue of messages and attempts to send those
|
||||
@ -25,8 +25,12 @@ module DA.Service.Logger.Impl.GCP (
|
||||
, test
|
||||
) where
|
||||
|
||||
import DA.Prelude
|
||||
import GHC.Generics(Generic)
|
||||
import Data.Int
|
||||
import Data.Tuple
|
||||
import Text.Read(readMaybe)
|
||||
import Data.Aeson as Aeson
|
||||
import Control.Monad
|
||||
import GHC.Stack
|
||||
import System.Directory
|
||||
import System.Environment
|
||||
@ -349,7 +353,7 @@ logOptOut = do
|
||||
optOut <- createLog env Lgr.Info msg
|
||||
unless exists do
|
||||
res <- sendLogs [optOut]
|
||||
when (DA.Prelude.null res) $
|
||||
when (Prelude.null res) $
|
||||
writeFile fp ""
|
||||
|
||||
-- | Reads the data file but doesn't check the values are valid
|
||||
@ -360,8 +364,8 @@ readDF s = do
|
||||
case lines t of
|
||||
[date, sent] -> Just (date, sent)
|
||||
_ -> Nothing
|
||||
date <- readMay date'
|
||||
sent <- readMay sent'
|
||||
date <- readMaybe date'
|
||||
sent <- readMaybe sent'
|
||||
pure DataFile{..}
|
||||
|
||||
-- | ensure the datatracker data is from today
|
||||
|
@ -17,7 +17,8 @@ import Control.Concurrent.MVar (MVar, newMVar, withMVar)
|
||||
import Control.Concurrent.STM.TVar (TVar, newTVarIO, readTVarIO, modifyTVar')
|
||||
import Control.Exception (bracket_)
|
||||
|
||||
import DA.Prelude
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
|
||||
import qualified Data.Aeson as Aeson
|
||||
import Data.Aeson.Encode.Pretty (encodePretty)
|
||||
|
@ -22,6 +22,7 @@ module Data.Text.Extended
|
||||
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.List.NonEmpty as NE
|
||||
import Data.Char
|
||||
|
||||
import Data.Text.Lens (packed, unpacked)
|
||||
import qualified Data.Text as T
|
||||
@ -29,13 +30,10 @@ import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Encoding.Error as T
|
||||
import Data.Text hiding (splitOn)
|
||||
|
||||
import DA.Prelude hiding (show)
|
||||
import qualified DA.Prelude
|
||||
|
||||
|
||||
-- | 'Show' a value and pack it into a strict 'Text' value.
|
||||
show :: Show a => a -> Text
|
||||
show = pack . DA.Prelude.show
|
||||
show = pack . Prelude.show
|
||||
|
||||
-- | A version of `T.splitOn` with the more precise non-empty list as its result type.
|
||||
splitOn :: Text
|
||||
|
@ -31,8 +31,7 @@ module Text.PrettyPrint.Annotated.Extended
|
||||
|
||||
|
||||
import qualified Data.Text as T
|
||||
|
||||
import DA.Prelude
|
||||
import Data.List
|
||||
|
||||
import Text.PrettyPrint.Annotated.HughesPJ
|
||||
hiding ( (<>), (<+>), empty, style, text, ($+$)
|
||||
@ -129,4 +128,3 @@ renderMonoidal style applyAnn convChar convText =
|
||||
Chr c -> (convChar c <> currentDoc, stack)
|
||||
Str s -> (convText s <> currentDoc, stack)
|
||||
PStr s -> (convText s <> currentDoc, stack)
|
||||
|
||||
|
@ -11,9 +11,8 @@ module DA.Service.JsonRpc
|
||||
) where
|
||||
|
||||
|
||||
import DA.Prelude
|
||||
|
||||
|
||||
import Data.Functor
|
||||
import Control.Monad.IO.Class
|
||||
import Control.Concurrent.Async.Lifted
|
||||
import Control.Concurrent.STM
|
||||
|
||||
@ -116,5 +115,3 @@ runServer loggerH snk src notifChan requestHandler notificationHandler = do
|
||||
|
||||
EventNop ->
|
||||
processEvents reqChan outChan
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@ da_haskell_library(
|
||||
"mtl",
|
||||
"scientific",
|
||||
"stm",
|
||||
"tagged",
|
||||
"template-haskell",
|
||||
"text",
|
||||
],
|
||||
|
@ -11,8 +11,7 @@ module DA.LanguageServer.Conduits
|
||||
|
||||
import Control.Monad.Catch (MonadThrow)
|
||||
import Control.Monad.Trans (MonadIO)
|
||||
|
||||
import DA.Prelude
|
||||
import Control.Monad.IO.Class
|
||||
|
||||
import qualified Data.Attoparsec.ByteString.Char8 as AP
|
||||
import qualified Data.ByteString.Char8 as B
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
|
||||
module DA.LanguageServer.Protocol(module DA.LanguageServer.Protocol) where
|
||||
import qualified Data.Map.Strict as MS
|
||||
@ -13,7 +12,7 @@ import qualified Data.Text as T
|
||||
import qualified Data.Scientific as Scientific
|
||||
|
||||
import DA.LanguageServer.TH (deriveJSON)
|
||||
import DA.Prelude
|
||||
import Data.Tagged
|
||||
import qualified DA.Service.JsonRpc as JsonRpc
|
||||
import qualified DA.Pretty as P
|
||||
|
||||
@ -576,7 +575,7 @@ data LogMessageParams = LogMessageParams
|
||||
-- Instances
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
concatSequenceA
|
||||
fmap concat $ sequenceA
|
||||
[ deriveJSON ''CompletionItem
|
||||
, deriveJSON ''CodeLensEntry
|
||||
, deriveJSON ''CodeLensParams
|
||||
|
Loading…
Reference in New Issue
Block a user