File tree Expand file tree Collapse file tree 4 files changed +20
-0
lines changed
Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ desugar emptyAnnotation md = runDesugar emptyAnnotation $
6767 >>= desugarTupleSection
6868 >>= desugarImplicitPrelude
6969 >>= desugarFFITypeSigs
70+ >>= desugarLCase
7071
7172-- | Desugaring
7273
@@ -129,6 +130,12 @@ desugarTupleCon = transformBi $ \ex -> case ex of
129130 body = Tuple l b (Var l . UnQual l <$> names)
130131 _ -> Nothing
131132
133+ -- | \case x of [...] -> \foo -> case foo of [...]
134+ desugarLCase :: (Data l , Typeable l ) => Module l -> Desugar l (Module l )
135+ desugarLCase = transformBiM $ \ ex -> case ex of
136+ LCase l alts -> withScopedTmpName l $ \ n -> return $ Lambda l [PVar l n] (Case l (Var l (UnQual l n)) alts)
137+ _ -> return ex
138+
132139desugarTupleSection :: (Data l , Typeable l ) => Module l -> Desugar l (Module l )
133140desugarTupleSection = transformBiM $ \ ex -> case ex of
134141 TupleSection l _ mes -> do
Original file line number Diff line number Diff line change @@ -332,6 +332,7 @@ defaultExtensions = map EnableExtension
332332 ,GADTs
333333 ,ImplicitPrelude
334334 ,KindSignatures
335+ ,LambdaCase
335336 ,NamedFieldPuns
336337 ,PackageImports
337338 ,RecordWildCards
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE LambdaCase #-}
2+ module LambdaCase where
3+
4+ f :: Int -> Bool
5+ f = \ case
6+ 2 -> True
7+ _ -> False
8+
9+ main :: Fay ()
10+ main = do
11+ print (f 2 )
Original file line number Diff line number Diff line change 1+ true
You can’t perform that action at this time.
0 commit comments