diff --git a/app/SimplifySyntax.hs b/app/SimplifySyntax.hs index 7b39845..32e25f2 100644 --- a/app/SimplifySyntax.hs +++ b/app/SimplifySyntax.hs @@ -297,6 +297,7 @@ hsExpToSimpExp x = simplifyExp $ case x of Exts.EnumFromTo l e1 e2 -> desugarEnums l "enumFromTo" [e1, e2] Exts.EnumFromThen l e1 e2 -> desugarEnums l "enumFromThen" [e1, e2] Exts.EnumFromThenTo l e1 e2 e3 -> desugarEnums l "enumFromThenTo" [e1, e2, e3] + Exts.MultiIf l rhss -> SeGuard l (fmap guardedRhsToSelectorAndVal rhss) _ -> error $ "Unsupported syntax in hsExpToSimpExp: " ++ show x -- Parsing @@ -306,7 +307,8 @@ customParseMode = Exts.defaultParseMode {Exts.extensions = [Exts.EnableExtension Exts.MultiParamTypeClasses, Exts.EnableExtension Exts.FlexibleContexts, - Exts.EnableExtension Exts.TupleSections + Exts.EnableExtension Exts.TupleSections, + Exts.EnableExtension Exts.MultiWayIf ] } diff --git a/test/VisualTranslateTests.hs b/test/VisualTranslateTests.hs index baf726c..0b35d9a 100644 --- a/test/VisualTranslateTests.hs +++ b/test/VisualTranslateTests.hs @@ -280,6 +280,17 @@ dataDeclTests = [ , "data Foo = Foo Int" ] +multiWayIfTests :: [String] +multiWayIfTests = [ + "y = if | x == 0 -> 1" + , "y = if\n\ + \ | x == 0 -> 1\n\ + \ | otherwise -> 2" + , "y = if\n\ + \ | x == 0 -> if {| y > z -> 2; | pizza -> 3} \n\ + \ | otherwise -> 2" + ] + testDecls :: [String] testDecls = mconcat [ simpleTests @@ -298,6 +309,7 @@ testDecls = mconcat [ , otherTests , typeSigTests , dataDeclTests + , multiWayIfTests ]