hslua-packaging: make liftPure* functions strict
This reduces the likelihood of memory corruption due to lazyness
problems.
+{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE OverloadedStrings #-}
@@ -101,29 +102,39 @@ defun :: Name -> a -> HsFnPrecursor e a
defun = toHsFnPrecursor (StackIndex 0)
-- | Turns a pure function into a monadic Lua function.
+--
+-- The resulting function is strict.
liftPure :: (a -> b)
-> (a -> LuaE e b)
-liftPure f = return . f
+liftPure f !a = return $! f a
-- | Turns a binary function into a Lua function.
+--
+-- The resulting function is strict in both its arguments.
liftPure2 :: (a -> b -> c)
-> (a -> b -> LuaE e c)
-liftPure2 f a b = return (f a b)
+liftPure2 f !a !b = return $! f a b
-- | Turns a ternary function into a Lua function.
+--
+-- The resulting function is strict in all of its arguments.
liftPure3 :: (a -> b -> c -> d)
-> (a -> b -> c -> LuaE e d)
-liftPure3 f a b c = return (f a b c)
+liftPure3 f !a !b !c = return $! f a b c
-- | Turns a quarternary function into a Lua function.
+--
+-- The resulting function is strict in all of its arguments.
liftPure4 :: (a -> b -> c -> d -> e)
-> (a -> b -> c -> d -> LuaE err e)
-liftPure4 f a b c d = return (f a b c d)
+liftPure4 f !a !b !c !d = return $! f a b c d
-- | Turns a quinary function into a Lua function.
+--
+-- The resulting function is strict in all of its arguments.
liftPure5 :: (a -> b -> c -> d -> e -> f)
-> (a -> b -> c -> d -> e -> LuaE err f)
-liftPure5 f a b c d e = return (f a b c d e)
+liftPure5 f !a !b !c !d !e = return $! f a b c d e
-- | Create a HaskellFunction precursor from a monadic function,
-- selecting the stack index after which the first function parameter
