From 8adfb453513a1c330908901a57d3714bd56284f4 Mon Sep 17 00:00:00 2001 From: Bartek Banachewicz Date: Wed, 14 May 2025 22:33:49 +0200 Subject: [PATCH] Build cleanly at 23.22 --- src/Turnip/Eval/Eval.hs | 24 +++++++++++------------- src/Turnip/Eval/TH.hs | 8 ++++---- src/Turnip/Repl.hs | 4 ++-- stack.yaml | 2 +- stack.yaml.lock | 12 ++++++++++++ 5 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 stack.yaml.lock diff --git a/src/Turnip/Eval/Eval.hs b/src/Turnip/Eval/Eval.hs index cad44ea..6a24e28 100644 --- a/src/Turnip/Eval/Eval.hs +++ b/src/Turnip/Eval/Eval.hs @@ -11,7 +11,7 @@ import Turnip.Eval.Util import Turnip.Eval.Metatables import Turnip.Eval.Closure -import Control.Monad.Except +import Control.Monad (forM_) import Control.Monad.State import qualified Data.Map as Map import Data.Maybe (isJust) @@ -142,7 +142,7 @@ eval (AST.Call fn args) = do fnV <- evalHead fn argVs <- evalArgsWithSpill args - case fnV of + case fnV of Function ref -> callRef ref argVs Table tref -> callMeta tref argVs x -> throwErrorStr $ "Trying to call something that doesn't eval to a function! (" ++ show x ++ ")" @@ -172,7 +172,7 @@ eval (AST.FieldRef t k) = do where getTableFieldWithMetatable :: TableRef -> Value -> LuaM [Value] - getTableFieldWithMetatable tr tk = + getTableFieldWithMetatable tr tk = rawGetTableField tr tk >>= \mv -> case mv of Just v -> return [v] Nothing -> do @@ -218,7 +218,7 @@ eval (AST.TableCons entries) = do lift $ do v <- evalHead ev - setTableField tr (Number (fromIntegral ix), v) + setTableField tr (Number (fromIntegral ix), v) -- TODO - should a comma-separated expression list have a dedicated AST node evalForExpressionList :: [AST.Expr] -> LuaM (Value, Value, Value) @@ -356,7 +356,7 @@ opEqual a b opNotEqual :: BinaryOperatorImpl opNotEqual Nil Nil = return [Boolean False] -opNotEqual a b +opNotEqual a b | a == b = return [Boolean False] | otherwise = (:[]) . Boolean . not <$> eqHelper a b @@ -401,7 +401,7 @@ opAnd a rhs = do if not $ coerceToBool [a] then return [a] else - (:[]) <$> evalHead rhs + (:[]) <$> evalHead rhs -------------- @@ -414,7 +414,7 @@ runUntil (h:t) f = do EmptyBubble -> runUntil t f -- if there was, return that bubble x -> return x - + runUntil [] _ = return EmptyBubble execBlock :: AST.Block -> LuaM Bubble @@ -482,8 +482,8 @@ execStmt (AST.For names (AST.ForIter explist) b) = do -- A function reference is (hopefully )returned after evaluating -- the explist fv <- case f of - Function fref -> getFunctionData fref - _ -> throwErrorStr "The iterator is not a function" + Function fref -> getFunctionData fref + _ -> throwErrorStr "The iterator is not a function" newCls <- makeNewTableWith . Map.fromList $ map (\n -> (Str n, Nil)) names @@ -518,7 +518,7 @@ execStmt (AST.While e b) = do -- While 'contains' the break bubble and turns it into -- an empty one, closing the statement. BreakBubble -> return EmptyBubble - -- Any other bubble (like return) can't be handled, + -- Any other bubble (like return) can't be handled, -- and is forwarded. x -> return x else @@ -616,7 +616,7 @@ assignLValue (AST.LFieldRef t k) v = do _ -> throwErrorStr "Trying to assign to a field of non-table" where setTableFieldWithNewindex :: TableRef -> (Value,Value) -> LuaM () - setTableFieldWithNewindex tr (tk, tv) = + setTableFieldWithNewindex tr (tk, tv) = rawGetTableField tr tk >>= \mv -> case mv of -- if key is already present, do regular insert Just _ -> regularSet @@ -633,5 +633,3 @@ assignLValue (AST.LFieldRef t k) v = do Nothing -> regularSet where regularSet = setTableField tr (tk, tv) - - diff --git a/src/Turnip/Eval/TH.hs b/src/Turnip/Eval/TH.hs index 35e5961..889c6ce 100644 --- a/src/Turnip/Eval/TH.hs +++ b/src/Turnip/Eval/TH.hs @@ -23,12 +23,12 @@ typeToName t = case t of BooleanT -> 'Eval.Boolean -- |Transforms a constructor Name into a pattern match for a newly introduced name -toPatName :: Name -> Q (Pat, Name) +toPatName :: Name -> Q (Pat, Name) toPatName p = do name <- newName "x" liftM2 (,) (conP p [varP name]) (pure name) -typeToMatch :: TypeT -> Q (Pat, Name) +typeToMatch :: TypeT -> Q (Pat, Name) typeToMatch = toPatName . typeToName type Entry = (Sig, String, Name, Name) @@ -39,7 +39,7 @@ entry sig luaName origName = do return (sig, luaName, tempName, origName) where toSafeSuffix = concat . map (show . ord) - + genDecls :: [Entry] -> Q [Dec] genDecls es = concat <$> mapM (\(sig, _, tempName, origName) -> genDec sig tempName origName) es @@ -67,7 +67,7 @@ genDec (Sig paramTs returnT) tempName origName = do -- the generated function accepts one param, with a pattern of (t1 : t2 : t3 : ... : _), -- where t1..tn are the types in its signature inputPattern :: Q Pat - inputPattern = return $ foldr (\par pat -> ConP '(:) [par, pat]) WildP listOfPatterns + inputPattern = return $ foldr (\par pat -> ConP '(:) [] [par, pat]) WildP listOfPatterns let params :: Q [Exp] diff --git a/src/Turnip/Repl.hs b/src/Turnip/Repl.hs index 6677cb7..a88f5ec 100644 --- a/src/Turnip/Repl.hs +++ b/src/Turnip/Repl.hs @@ -13,6 +13,7 @@ import Text.ParserCombinators.Parsec (Parser, ParseError, parse, (<|>), try, eof import Paths_Turnip (version) import Data.Version (showVersion) +import Control.Monad (when, forever) import Control.Monad.State import System.IO import Control.Monad.Except (catchError) @@ -44,7 +45,7 @@ disableBuffering = hSetBuffering stdout NoBuffering repl :: ReplConfig -> IO () repl cfg = do - disableBuffering + disableBuffering putStrLn $ "Turnip REPL v" ++ showVersion version ++ "\n" _ <- flip runLuaMT defaultCtx $ do @@ -72,4 +73,3 @@ printError err = liftIO . putStrLn $ "Lua error " ++ show err printParseError :: MonadIO m => ParseError -> LuaMT m () printParseError err = liftIO . putStrLn $ "Parse error " ++ show err - diff --git a/stack.yaml b/stack.yaml index 516dc18..af515b7 100644 --- a/stack.yaml +++ b/stack.yaml @@ -2,7 +2,7 @@ # For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/ # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) -resolver: lts-18.5 +resolver: lts-23.22 # Local packages, usually specified by relative directory name packages: diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..fb04626 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + sha256: f8c8f95e57e436cee7c053b6f424e2c07a1020304a5583f3568cd9521443c340 + size: 683838 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/22.yaml + original: lts-23.22