packages feed

hslua 1.1.1 → 1.1.2

raw patch · 4 files changed

+31/−7 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Foreign.Lua: pushList :: Pusher a -> [a] -> Lua ()
+ Foreign.Lua: pushList :: Pushable a => [a] -> Lua ()
- Foreign.Lua.Types.Pushable: pushList :: Pusher a -> [a] -> Lua ()
+ Foreign.Lua.Types.Pushable: pushList :: Pushable a => [a] -> Lua ()

Files

CHANGELOG.md view
@@ -1,8 +1,23 @@ ## Changelog +### 1.1.2++Released 2020-06-02++- Revert signature of function `pushList` to it's proper 1.1+  value. This fixes a mistake which made caused the 1.1.1 release+  to be in violation of the PVP versioning policy.++- Module Foreign.Lua.Peek: add function `pushKeyValuePairs` (Alex+  Loomis).+ ### 1.1.1  Released 2020-06-02++*WARNING*: This version does not conform to the PVP versioning+policy, due to a unintended signature change of function+`pushList`. It is recommended not to use this version.  - New module Foreign.Lua.Push: provides functions which marshal   and push Haskell values onto Lua's stack.
hslua.cabal view
@@ -1,5 +1,5 @@ name:                hslua-version:             1.1.1+version:             1.1.2 synopsis:            Bindings to Lua, an embeddable scripting language description:         HsLua provides bindings, wrappers, types, and helper                      functions to bridge Haskell and <https://www.lua.org/ Lua>.
src/Foreign/Lua/Push.hs view
@@ -85,6 +85,13 @@      then pushnumber (realToFrac f :: Lua.Number)      else pushString (showGFloat Nothing f "") +-- | Push list of pairs as default key-value Lua table.+pushKeyValuePairs :: Pusher a -> Pusher b -> Pusher [(a,b)]+pushKeyValuePairs pushKey pushValue m = do+  let addValue (k, v) = pushKey k *> pushValue v *> rawset (-3)+  newtable+  mapM_ addValue m+ -- | Push list as numerically indexed table. pushList :: Pusher a -> [a] -> Lua () pushList push xs = do@@ -94,10 +101,7 @@  -- | Push 'Map' as default key-value Lua table. pushMap :: Pusher a -> Pusher b -> Pusher (Map a b)-pushMap pushKey pushValue m = do-  let addValue (k, v) = pushKey k *> pushValue v *> rawset (-3)-  newtable-  mapM_ addValue (toList m)+pushMap pushKey pushValue m = pushKeyValuePairs pushKey pushValue $ toList m  -- | Push a 'Set' as idiomatic Lua set, i.e., as a table with the set -- elements as keys and @true@ as values.
src/Foreign/Lua/Types/Pushable.hs view
@@ -23,10 +23,11 @@ import Data.Text (Text) import Data.Set (Set) import Foreign.Lua.Core as Lua-import Foreign.Lua.Push as Push+import Foreign.Lua.Push hiding (pushList) import Foreign.Ptr (Ptr)  import qualified Data.ByteString.Lazy as BL+import qualified Foreign.Lua.Push as Push  -- | A value that can be pushed to the Lua stack. class Pushable a where@@ -77,13 +78,17 @@   push = pushString  instance Pushable a => Pushable [a] where-  push = pushList push+  push = Push.pushList push  instance (Pushable a, Pushable b) => Pushable (Map a b) where   push = pushMap push push  instance Pushable a => Pushable (Set a) where   push = pushSet push++-- | Push list as numerically indexed table.+pushList :: Pushable a => [a] -> Lua ()+pushList = Push.pushList push  -- -- Tuples