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

Get rid of an incomplete pattern match #247

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions packages/backend-glr/src/Happy/Backend/GLR/ProduceCode.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Extract the string that comes before the module declaration...
> . table_text

> lib_content lib_text
> = let (pre,_drop_me : post) = break (== "fakeimport DATA") $ lines lib_text
> = let (pre,post) = break (== "fakeimport DATA") $ lines lib_text
Copy link
Member

Choose a reason for hiding this comment

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

Should we make such a change? I think it is hurting code comprehensibility more than helping it.
The current formulation makes clear that the _drop_me : post match MUST succeed, even if GHC does not see it.
The new formulation clouds this insight.
So, I am against such a change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes it would be better to add an explicit pattern match with an error .... It would be even better to try to use NonEmpty.

Copy link
Member

Choose a reason for hiding this comment

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

NonEmpty is available from base-compat for old GHC versions back to 7.0 (base-4.3), so that would not be a problem for keeping all currently supported GHC versions.

> in
> unlines [ "{-# LANGUAGE CPP #-}"
> , unlines
Expand All @@ -222,7 +222,7 @@ Extract the string that comes before the module declaration...
> , start ++ " = glr_parse "
> , "use_filtering = " ++ show use_filtering
> , "top_symbol = " ++ prefix ++ start_prod
> , unlines post
> , unlines (drop 1 post)
> ]
> start_prod = token_names g ! (let (_,_,i,_) = head $ starts g in i)
> use_filtering = case options of (_, UseFiltering,_) -> True
Expand Down