-
Notifications
You must be signed in to change notification settings - Fork 14
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
How aggressive should desugaring be? #16
Comments
One unresolved question about match flattening is how it impacts the performance of libraries that consume the desugared output. |
There is a similar question about Or patterns (which will debut in GHC 9.12) when thinking about the tradeoff between making data Pat
= ...
| OrP (NonEmpty Pat) However, it's less clear if we need a corresponding data T = T1 String | T2 Int | T3 Int
stringOfT :: T -> Maybe String
stringOfT (T1 s) = Just s
stringOfT (T2{}; T3{}) = Nothing GHC will desugar stringOfT :: T -> Maybe String
stringOfT t =
case t of
T1 s -> Just s
T2 _ -> Nothing
T3 _ -> Nothing This Core function only makes use of simple constructor patterns. We could imagine doing a similar desugaring in My inclination is to add EDIT: On the other hand, perhaps we don't even want to add support for |
th-desugar doesn't currently try as hard as it could. But, it's not clear that trying harder would be a benefit. Here are some ways it could try harder:
DPat
type, which would contain onlyDConPa Name [Name]
,DLitPa ...
andDWildPa
. And, at the cost of some code duplication,DWildPa
could be restricted to be only with literal patterns.I don't know the right answers here. My hunch is that being as aggressive as possible is good for singletons...
The text was updated successfully, but these errors were encountered: