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

Vendor sources of prettyprinter-1.6.0 #1263

Merged
merged 2 commits into from
Aug 1, 2023
Merged
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
26 changes: 9 additions & 17 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,27 @@ constraints: sbv <10

-- these upper bounds are required in order to not break payload validation in chainweb
constraints: base16-bytestring <1
constraints: prettyprinter <1.6.1
constraints: base64-bytestring <1.1

allow-newer: base64-bytestring:*
allow-newer: base16-bytestring:*
allow-newer: prettyprinter:*

-- test upper bounds
constraints: hspec-golden <0.2,

-- The following fork provides trifecta-2.`1.1.1 which is compatible with
-- hashable >=1.4 and prettyprinter <1.7
--
-- trifeta >=2.1.2 requires a prettyprinter >=1.7, which isn't supported by
-- pact (because it would break mainnet replays). trifecta ==2.1.1 does not
-- support hashable >=1.4.
--
source-repository-package
type: git
tag: f991ffb74a1a1ab86f14e751d7c4f4ba549785b3
location: https://github.com/hackage-package-forks/trifecta
--sha256: sha256-m+IplwZ9DxJt6Mzkq961BzgiboHJul6w1uwDUqXnljo=

source-repository-package
type: git
tag: e43073d0b8d89d9b300980913b842f4be339846d
location: https://github.com/kadena-io/pact-json
--sha256: sha256-ZWbAId0JBaxDsYhwcYUyw04sjYstXyosSCenzOvUxsQ=

-- Required for GHC-9.6

-- These packages are tightly bundled with GHC. The rules ensure that
-- our builds use the version that ships with the GHC version that is
-- used for the build.
--
allow-newer: *:template-haskell
allow-newer: *:base
allow-newer: *:ghc-prim

-- Patch merged into master (upcoming verison 10.0). We are currently using 9.2
source-repository-package
Expand All @@ -56,3 +44,7 @@ allow-newer: servant:*

-- Required by trifecta (e.g. to allow mtl >=2.3)
allow-newer: trifecta:*

-- servant-0.20 does not yet support aeson-2.2
--
constraints: aeson <2.2
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change unrelated to the prettyprinter vendoring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is related because the bound on prettyprinter indirectly implied aeson <2.2

25 changes: 23 additions & 2 deletions pact.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ flag tests-in-lib
default: False
manual: True

-- -------------------------------------------------------------------------- --
-- Internal: prettyprinter-1.6.0 and prettyprinter-ansi-terminal-1.1.2

library pact-prettyprinter
hs-source-dirs: vendored/prettyprinter-1.6.0/src
default-language: Haskell2010
exposed-modules:
Data.Text.Prettyprint.Doc
Data.Text.Prettyprint.Doc.Internal
Data.Text.Prettyprint.Doc.Render.String
Data.Text.Prettyprint.Doc.Render.Terminal
Data.Text.Prettyprint.Doc.Render.Text
Data.Text.Prettyprint.Doc.Render.Util.Panic
Data.Text.Prettyprint.Doc.Render.Util.StackMachine
Data.Text.Prettyprint.Doc.Symbols.Ascii
Data.Text.Prettyprint.Doc.Compat
build-depends:
, base >= 4.5 && < 5
, text >= 1.2
, ansi-terminal >=0.4
, prettyprinter >= 1.7

-- -------------------------------------------------------------------------- --
-- Pact library

Expand Down Expand Up @@ -148,6 +170,7 @@ library
Pact.Utils.Servant

build-depends:
, pact-prettyprinter
, base >= 4.18.0.0
, Decimal >=0.4.2
, QuickCheck >=2.12.6.1
Expand Down Expand Up @@ -177,8 +200,6 @@ library
, pact-json >=0.1
, pact-time >=0.2
, parsers >=0.12.4
, prettyprinter >=1.2
, prettyprinter-ansi-terminal >=1.1
, quickcheck-instances >=0.3
, reflection
, scientific >= 0.3
Expand Down
5 changes: 3 additions & 2 deletions src/Pact/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import qualified Data.Set as S
import Data.String
import Data.Text (Text,unpack, pack)
import Data.Text.Encoding (encodeUtf8, decodeUtf8)
import Data.Text.Prettyprint.Doc.Compat (docToInternal)
import qualified Data.Vector as V

import Text.Megaparsec as MP
Expand Down Expand Up @@ -724,7 +725,7 @@ _compileF :: FilePath -> IO (Either PactError [Term Name])
_compileF f = _parseF f >>= _compile id

handleParseError :: TF.Result a -> IO a
handleParseError (TF.Failure f) = putDoc (TF._errDoc f) >> error "parseFailed"
handleParseError (TF.Failure f) = putDoc (docToInternal $ TF._errDoc f) >> error "parseFailed"
handleParseError (TF.Success a) = return a

_compileWith :: Compile a -> (ParseState CompileState -> ParseState CompileState) ->
Expand Down Expand Up @@ -768,7 +769,7 @@ _compileFile :: FilePath -> IO [Term Name]
_compileFile f = do
p <- _parseF f
rs <- case p of
(TF.Failure e) -> putDoc (TF._errDoc e) >> error "Parse failed"
(TF.Failure e) -> putDoc (docToInternal $ TF._errDoc e) >> error "Parse failed"
(TF.Success (es,s)) -> return $ map (compile def s) es
case sequence rs of
Left e -> throwIO $ userError (show e)
Expand Down
3 changes: 2 additions & 1 deletion src/Pact/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import qualified Data.Map.Strict as M
import Data.Monoid (appEndo)
import Data.Text (Text, pack, unpack)
import Data.Text.Encoding (encodeUtf8, decodeUtf8)
import Data.Text.Prettyprint.Doc.Compat (docToInternal)
import Data.Foldable(traverse_)

import Text.Trifecta as TF hiding (line,err,try,newline)
Expand Down Expand Up @@ -201,7 +202,7 @@ getDelta = do
handleParse :: TF.Result [Exp Parsed] -> ([Exp Parsed] -> Repl (Either String a)) -> Repl (Either String a)
handleParse (TF.Failure e) _ = do
mode <- use rMode
let errDoc = _errDoc e
let errDoc = docToInternal (_errDoc e)
outStrLn HErr $ renderPrettyString' (colors mode) $ unAnnotate errDoc
return $ Left $ renderCompactString' $ unAnnotate $ errDoc
handleParse (TF.Success es) a = a es
Expand Down
2 changes: 1 addition & 1 deletion src/Pact/Types/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import Data.Text.Prettyprint.Doc
encloseSep, space, nest, align, hardline, tupled, indent, equals, reAnnotate,
reAnnotateS, fillSep)
import qualified Data.Text.Prettyprint.Doc as PP
import qualified Data.Text.Prettyprint.Doc.Internal.Type as PP
import qualified Data.Text.Prettyprint.Doc.Internal as PP
import qualified Data.Text.Prettyprint.Doc.Render.String as PP
import Data.Text.Prettyprint.Doc.Render.Terminal
(color, Color(..), AnsiStyle)
Expand Down
23 changes: 23 additions & 0 deletions vendored/prettyprinter-1.6.0/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright 2008, Daan Leijen and Max Bolingbroke, 2016 David Luposchainsky. All
rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

This software is provided by the copyright holders "as is" and any express or
implied warranties, including, but not limited to, the implied warranties of
merchantability and fitness for a particular purpose are disclaimed. In no event
shall the copyright holders be liable for any direct, indirect, incidental,
special, exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or profits; or
business interruption) however caused and on any theory of liability, whether in
contract, strict liability, or tort (including negligence or otherwise) arising
in any way out of the use of this software, even if advised of the possibility
of such damage.
Loading