mirror of
https://github.com/rgleichman/glance.git
synced 2024-11-23 08:27:18 +03:00
Support MultiWayIf.
This commit is contained in:
parent
34e054133f
commit
b82e5f3b93
@ -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
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user