From bd797a01bc3a5c999c9cfd200ab039ed0d65731c Mon Sep 17 00:00:00 2001 From: Victor Taelin Date: Fri, 1 Nov 2024 10:52:30 -0300 Subject: [PATCH] change when syntax --- src/Kind/Parse.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Kind/Parse.hs b/src/Kind/Parse.hs index f46714c37..bc0f4e826 100644 --- a/src/Kind/Parse.hs +++ b/src/Kind/Parse.hs @@ -975,7 +975,7 @@ parseIf = withSrc $ do -- When -- ---- --- when fn x { c0: v0 c1: v1 _: df } +-- when fn x { c0: v0 c1: v1 } else { df } -- -------------------------------------------------------- desugars to -- if (fn x c0) { v0 } else if (fn x c1) { v1 } else { df } @@ -985,22 +985,20 @@ parseWhen = withSrc $ do val <- parseTerm char_skp '{' cases <- P.many $ do - P.notFollowedBy (char_skp '_') cond <- parseTerm char_skp ':' body <- parseTerm return (cond, body) - defaultCase <- do - char_skp '_' - char_skp ':' - body <- parseTerm - return $ body + char_skp '}' + string_skp "else" + char_skp '{' + elseCase <- parseTerm char '}' return $ foldr (\ (cond, body) acc -> App (Mat [("True", body), ("False", acc)]) (App (App fun val) cond)) - defaultCase + elseCase cases -- Match