desugarL1Patterns :: L1.L1Expression -> State DesugarTmp L1.L1Expression
desugarL1Patterns ex@(L1.L1ExCase ss expr (Right values)) =
  -- We sequentially test each value for a match, and if they match, we then go ahead and try to extract the contents.
  let
    addPatternToCase otherwiseEx (pat, ifEx) =
      L1.L1ExCase ss
        <$> (testPatternUsing expr pat)
        <*> (
              (\x y -> Left [x, y])
               <$> ((,) (pathGlobal ss "true") <$>
                      (ignoreArgumentLambda ss =<< patternToExtractLambdas expr pat ifEx))
               <*> ((,) (pathGlobal ss "false") <$>
                    ignoreArgumentLambda ss otherwiseEx)
            )
  in
    foldM addPatternToCase (makeErrorExpression ss $ "Nothing matched pattern at " <> (BSC.pack . show $ ss)) (reverse values)
desugarL1Patterns :: L1.L1Expression -> State DesugarTmp L1.L1Expression
desugarL1Patterns ex@(L1.L1ExCase ss expr (Right values)) =
  -- We sequentially test each value for a match, and if they match, we then go ahead and try to extract the contents.
  let
    addPatternToCase otherwiseEx (pat, ifEx) =
      L1.L1ExCase ss
        <$> (testPatternUsing expr pat)
        <*> (
              (\x y -> Left [x, y])
               <$> ((,) (pathGlobal ss "true") <$>
                      (ignoreArgumentLambda ss =<< patternToExtractLambdas expr pat ifEx))
               <*> ((,) (pathGlobal ss "false") <$>
                    ignoreArgumentLambda ss otherwiseEx)
            )
  in
    foldM addPatternToCase (makeErrorExpression ss $ "Nothing matched pattern at " <> (BSC.pack . show $ ss)) (reverse values)
desugarL1Patterns ex@(L1.L1ExCase ss expr (Right values)) =
  -- We sequentially test each value for a match, and if they match, we then go ahead and try to extract the contents.
  let
    addPatternToCase otherwiseEx (pat, ifEx) =
      L1.L1ExCase ss
        <$> (testPatternUsing expr pat)
        <*> (
              (\x y -> Left [x, y])
               <$> ((,) (pathGlobal ss "true") <$>
                      (ignoreArgumentLambda ss =<< patternToExtractLambdas expr pat ifEx))
               <*> ((,) (pathGlobal ss "false") <$>
                    ignoreArgumentLambda ss otherwiseEx)
            )
  in
    foldM addPatternToCase (makeErrorExpression ss $ "Nothing matched pattern at " <> (BSC.pack . show $ ss)) (reverse values)