packages feed

hslua-module-text 0.2.0 → 0.2.1

raw patch · 4 files changed

+33/−53 lines, 4 filesdep ~hsluaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hslua

API changes (from Hackage documentation)

+ Foreign.Lua.Module.Text: pushModule :: Lua NumResults

Files

ChangeLog.md view
@@ -1,5 +1,13 @@ # Revision history for hslua-module-text +## 0.2.1 -- 2019-05-04++- Require at least HsLua v1.0.3: that version has better support+  for modules.++- Rename `pushModuleText` to `pushModule`. The old name is keeped+  as an alias for now.+ ## 0.2.0 -- 2018-09-24  - Use hslua 1.0.
hslua-module-text.cabal view
@@ -1,5 +1,5 @@ name:                hslua-module-text-version:             0.2.0+version:             0.2.1 synopsis:            Lua module for text description:         UTF-8 aware subset of Lua's `string` module. homepage:            https://github.com/hslua/hslua-module-text@@ -7,12 +7,17 @@ license-file:        LICENSE author:              Albert Krewinkel maintainer:          albert+hslua@zeitkraut.de-copyright:           © 2017–2018 Albert Krewinkel+copyright:           © 2017–2019 Albert Krewinkel category:            Foreign build-type:          Simple extra-source-files:  ChangeLog.md                      test/hstext-test.lua cabal-version:       >=1.10+tested-with:         GHC == 7.10.3+                   , GHC == 8.0.2+                   , GHC == 8.2.2+                   , GHC == 8.4.4+                   , GHC == 8.6.5  source-repository head   type:              git@@ -22,7 +27,7 @@   exposed-modules:     Foreign.Lua.Module.Text   build-depends:       base       >= 4.7    && < 5                      , bytestring >= 0.10.2 && < 0.11-                     , hslua      >= 1.0    && < 1.1+                     , hslua      >= 1.0.3  && < 1.2                      , text       >= 1      && < 1.3   hs-source-dirs:      src   default-language:    Haskell2010
src/Foreign/Lua/Module/Text.hs view
@@ -1,28 +1,7 @@-{--Copyright © 2017–2018 Albert Krewinkel--Permission is hereby granted, free of charge, to any person obtaining a copy-of this software and associated documentation files (the "Software"), to deal-in the Software without restriction, including without limitation the rights-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell-copies of the Software, and to permit persons to whom the Software is-furnished to do so, subject to the following conditions:--The above copyright notice and this permission notice shall be included in-all copies or substantial portions of the Software.--THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN-THE SOFTWARE.--} {-# LANGUAGE OverloadedStrings #-} {-| Module      : Foreign.Lua.Module.Text-Copyright   : © 2017–2018 Albert Krewinkel+Copyright   : © 2017–2019 Albert Krewinkel License     : MIT Maintainer  : Albert Krewinkel <tarleb+hslua@zeitkraut.de> Stability   : alpha@@ -31,7 +10,8 @@ Provide a lua module containing a selection of useful Text functions. -} module Foreign.Lua.Module.Text-  ( pushModuleText+  ( pushModule+  , pushModuleText   , preloadTextModule   )where @@ -43,38 +23,25 @@ import qualified Foreign.Lua as Lua import qualified Data.Text as T --- | Pushes the @text@ module to the lua stack.-pushModuleText :: Lua NumResults-pushModuleText = do+-- | Pushes the @text@ module to the Lua stack.+pushModule :: Lua NumResults+pushModule = do   Lua.newtable-  addFunction "lower" (return . T.toLower :: Text -> Lua Text)-  addFunction "upper" (return . T.toUpper :: Text -> Lua Text)-  addFunction "reverse" (return . T.reverse :: Text -> Lua Text)-  addFunction "len" (return . fromIntegral . T.length :: Text -> Lua Lua.Integer)-  addFunction "sub" sub+  Lua.addfunction "lower" (return . T.toLower :: Text -> Lua Text)+  Lua.addfunction "upper" (return . T.toUpper :: Text -> Lua Text)+  Lua.addfunction "reverse" (return . T.reverse :: Text -> Lua Text)+  Lua.addfunction "len" (return . fromIntegral . T.length :: Text -> Lua Lua.Integer)+  Lua.addfunction "sub" sub   return 1 +-- | Legacy alias for '@pushModule@'.+pushModuleText :: Lua NumResults+pushModuleText = pushModule+ -- | Add the text module under the given name to the table of preloaded -- packages. preloadTextModule :: String -> Lua ()-preloadTextModule = flip addPackagePreloader pushModuleText---- | Registers a preloading function. Takes an module name and the Lua operation--- which produces the package.-addPackagePreloader :: String -> Lua NumResults -> Lua ()-addPackagePreloader name modulePusher = do-  Lua.getfield Lua.registryindex Lua.preloadTableRegistryField-  Lua.pushHaskellFunction modulePusher-  Lua.setfield (-2) name-  Lua.pop 1---- | Attach a function to the table at the top of the stack, using the given--- name.-addFunction :: ToHaskellFunction a => String -> a -> Lua ()-addFunction name fn = do-  Lua.push name-  Lua.pushHaskellFunction fn-  Lua.rawset (-3)+preloadTextModule = flip Lua.preloadhs pushModule  -- | Returns a substring, using Lua's string indexing rules. sub :: Text -> Lua.Integer -> Lua.Optional Lua.Integer -> Lua Text
test/test-hslua-module-text.hs view
@@ -1,5 +1,5 @@ {--Copyright © 2017–2018 Albert Krewinkel+Copyright © 2017–2019 Albert Krewinkel  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal