-
Notifications
You must be signed in to change notification settings - Fork 76
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
Provide context parsing in the mkMessage
function
#283
Conversation
mkMessage
function
.github/workflows/tests.yml
Outdated
# Is taken from the https://github.com/yesodweb/yesod/blob/master/.github/workflows/tests.yml template | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment probably isn't necessary.
Text/Shakespeare/I18N.hs
Outdated
@@ -62,22 +63,22 @@ module Text.Shakespeare.I18N | |||
) where | |||
|
|||
import Language.Haskell.TH.Syntax hiding (makeRelativeToProject) | |||
import Control.Applicative ((<$>)) | |||
--import Control.Applicative ((<$>)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this import isn't necessary, it's better just to delete the line.
Text/Shakespeare/I18N.hs
Outdated
import Control.Arrow ((***)) | ||
import Data.Monoid (mempty, mappend) | ||
--import Data.Monoid (mempty, mappend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can delete this line also.
Text/Shakespeare/I18N.hs
Outdated
|
||
parseName = do | ||
cxt' <- option [] parseContext | ||
-- name' <- parseWord -- This one is no longer needed as a separate argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just keep the code that we need 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I will tidy up the source files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tidying up. Now we just need to demonstrate that this is not a breaking change, and that it produces correct code for the scenario documented in the associated issue (and we should squash before merging).
### 2.1.1 | ||
|
||
* Add support for `TypeApplications` inside Shakespeare quasiquotes | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason why this changelog entry was removed? This looks like a mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Hackage the version 2.1.1 is the last one and is already deprecated.
https://hackage.haskell.org/package/shakespeare-2.1.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but it shouldn't be removed even if it's deprecated. The deprecated version should continue to exist in the version history.
Text/Shakespeare/I18N.hs
Outdated
@@ -255,13 +301,13 @@ conP name = ConP name [] | |||
conP = ConP | |||
#endif | |||
|
|||
toCon :: String -> SDef -> Con | |||
toCon :: String -> SDef -> Con |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not introduce trailing whitespace.
shakespeare.cabal
Outdated
version: 2.1.1 | ||
version: 2.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this number to go up, not down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be changed to 2.1.2
it "parseDeref parse single type applications" $ do | ||
runParser parseDeref () "" "x @y" `shouldBe` | ||
Right | ||
(DerefBranch | ||
(DerefIdent (Ident "x")) | ||
(DerefType "y")) | ||
it "parseDeref parse unit type applications" $ do | ||
runParser parseDeref () "" "x @()" `shouldBe` | ||
Right | ||
(DerefBranch | ||
(DerefIdent (Ident "x")) | ||
(DerefType "()")) | ||
it "parseDeref parse compound type applications" $ do | ||
runParser parseDeref () "" "x @(Maybe String)" `shouldBe` | ||
Right | ||
(DerefBranch | ||
(DerefIdent (Ident "x")) | ||
(DerefType "Maybe String")) | ||
it "parseDeref parse single @ as operator" $ do | ||
runParser parseDeref () "" "x @ y" `shouldBe` | ||
Right | ||
(DerefBranch | ||
(DerefBranch (DerefIdent (Ident "@")) (DerefIdent (Ident "x"))) | ||
(DerefIdent (Ident "y"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these tests removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is strange. I have not edited the file. Should I add these lines into the BaseSpec.hs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a minor git accident then 🙂 You can just revert this change.
Text/Shakespeare/I18N.hs
Outdated
cxt -- Here the parsed context should be added, otherwise [] | ||
(ConT ''RenderMessage `AppT` (if ' ' `elem` master' then let (ts, us) = break (== ' ') . filter (\x -> x /= '(' && x /= ')') $ master' in let us1 = filter (/= ' ') us in ParensT (ConT (mkName ts) `AppT` VarT (mkName us1)) else ConT $ mkName master') `AppT` ConT mname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a nicer way to format this? I would prefer to see lines limited to 80 columns.
[ FunD (mkName "renderMessage") $ c1 ++ c2 ++ [c3] | ||
] | ||
] | ||
|
||
toClauses :: String -> String -> (Lang, [Def]) -> Q [Clause] | ||
where (dt1, cxt0) = case (parse parseName "" dt) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's improve the formatting of all the new parsing code here.
…ssue Added some code improvements
Provided context parsing in the mkMessage function. Resolves issue #282: mkMessage should support context parsing
CI passed successfully. See the link below:
https://github.com/Oleksandr-Zhabenko/shakespeare/actions/runs/10403325875