ref: b782a5b149b6f1ad271bc61909ba8eca7fb28a7c
parent: e0bff6c183d9ed36fc8e16e498538265f7f263fd
author: Lennart Augustsson <lennart@augustsson.net>
date: Sat Jan 4 11:50:39 EST 2025
Small improvement for list comprehensions.
--- a/src/MicroHs/Desugar.hs
+++ b/src/MicroHs/Desugar.hs
@@ -245,6 +245,8 @@
dsCompr e [] l = EApp (EApp consCon e) l
dsCompr e (SThen c : ss) l = EIf c (dsCompr e ss l) l
dsCompr e (SLet ds : ss) l = ELet ds (dsCompr e ss l)
+-- Special case for the idiom [ ... | ..., p <- [x], ... ]. This is a little more efficient.
+dsCompr e (SBind p (EListish (LList [x])) : ss) l = ECase x [(p, oneAlt $ dsCompr e ss l), (EVar dummyIdent, oneAlt l)]
dsCompr e xss@(SBind p g : ss) l = ELet [hdef] (EApp eh g)
where
hdef = BFcn h [eqn1, eqn2, eqn3]