Add QuasiQuoter for proto3 syntax lifting to DotProto#296
Add QuasiQuoter for proto3 syntax lifting to DotProto#296
QuasiQuoter for proto3 syntax lifting to DotProto#296Conversation
| import qualified Turtle hiding (encodeString) | ||
| import qualified Turtle.Compat as Turtle (encodeString) | ||
| import Turtle (FilePath, (</>), (<.>)) | ||
| import NeatInterpolation qualified as Neat |
There was a problem hiding this comment.
Why did you change just this one import to use ImportQualifiedPost, but not the others?
There was a problem hiding this comment.
This import was removed and I added it back with post qualification.
There was a problem hiding this comment.
I would prefer to minimize diffs meanwhile. I'm not a huge fan of formatting tools, but I'm fine with manually imposing a style on imports. My current favorite is alphabetized by module name, always using ImportQualifiedPost so that that module name comes first, saves on indentation, and makes it easy to just use a sort-lines feature in whatever editor is handy. For long identifier lists I typically move them to the next line and word-wrap them.
| (</>)) | ||
| import Turtle.Format ((%)) | ||
| import qualified Turtle.Format as F | ||
| import NeatInterpolation qualified as Neat |
There was a problem hiding this comment.
Why did you change just this one import to use ImportQualifiedPost, but not the others?
There was a problem hiding this comment.
I removed the import and added it back with the post qualification. We can format the entire repo with a formatting tool later on I don't know if it matters.
There was a problem hiding this comment.
I would prefer to minimize diffs meanwhile. I'm not a huge fan of formatting tools, but I'm fine with manually imposing a style on imports. My current favorite is alphabetized by module name, always using ImportQualifiedPost so that that module name comes first, saves on indentation, and makes it easy to just use a sort-lines feature in whatever editor is handy. For long identifier lists I typically move them to the next line and word-wrap them.
| {-# LANGUAGE TupleSections #-} | ||
| {-# LANGUAGE TypeApplications #-} | ||
| {-# LANGUAGE TypeOperators #-} | ||
| {-# LANGUAGE QuasiQuotes #-} |
There was a problem hiding this comment.
Why move this pragma from its alphabetical position?
| {-# LANGUAGE QuasiQuotes #-} | ||
| {-# LANGUAGE RankNTypes #-} | ||
| {-# LANGUAGE RecordWildCards #-} | ||
| {-# LANGUAGE QuasiQuotes #-} |
There was a problem hiding this comment.
Why move this pragma out of its alphabetical position?
There was a problem hiding this comment.
I removed it and unremoved it.
|
|
||
| parseProtoWithFile :: Path -> String -> String -> Either ParseError DotProto | ||
| -- | Parse a protobuf source string with an associated module path and file | ||
| -- path. |
There was a problem hiding this comment.
What are the module path and file path used for? Just error messages? Whatever the answer, I think it would be good to include that detail in the comment.
| ) | ||
| where | ||
|
|
||
| import Control.Applicative (liftA2) |
There was a problem hiding this comment.
Comment only: I guess this is the sort of import that would make warnings-as-errors a pain for hackage maintainers, because it is sometimes redundant and sometimes required, depending upon the version of base.
|
|
||
| case parseProtoWithFile pkg (show modName) input of | ||
| Left err -> fail (show err) | ||
| Right expr -> TH.lift expr No newline at end of file |
There was a problem hiding this comment.
It is probably best to end each line with a newline, in order to be friendly to various tools. Not a big deal, though.
This pull request adds a quasi-quoter that can be used to embed a
*.protofile in Haskell. The use case I needed theproto3 :: QuasiQuoterfor was bringing*.protofiles used for testing (i.e. files under{githubRoot}/test-file) into the test suite as a series of quasi-quote splices containing the file source in a Haskell module.This is part of a string of work to remove bootstrapping from the Nix build process as it is the cause of many issues in CI and frequently blocks additions of features. The plan is to:
./test-files/to a Haskell module../test-files/*. Test files will be rendered from the Haskell splices containing the protobuf source.turtlecalls in the test suite for testing code generation can be removed.turtlecalls are removed from the test suite (example) the bootstrapping charge is pushed on totemplate-haskellwhere far less moving parts are required to check that our sample protobuf files are being compiled correctly.shell.nixanddefault.nixwill be replaced by aflake.nixAll of this should eliminate future issues in CI and speed up build time significantly.