hslua-module-text: make use of new convenience functions
@@ -24,7 +24,6 @@ module HsLua.Module.Text
import Prelude hiding (reverse)
import Data.Text (Text)
import Data.Maybe (fromMaybe)
-import HsLua.Marshalling (peekIntegral, peekText, pushIntegral, pushText)
import HsLua.Packaging
import qualified Data.Text as T
@@ -53,15 +52,15 @@ documentedModule = Module
len :: DocumentedFunction e
len = defun "len"
### liftPure T.length
- <#> textParam "s"
- =#> intResult "length"
+ <#> textParam "s" "UTF-8 encoded string"
+ =#> integralResult "length"
#? "Determines the number of characters in a string."
-- | Wrapper for @'T.toLower'@.
lower :: DocumentedFunction e
lower = defun "lower"
### liftPure T.toLower
- <#> textParam "s"
+ <#> textParam "s" "UTF-8 string to convert to lowercase"
=#> textResult "Lowercase copy of `s`"
#? "Converts a string to lower case."
@@ -69,7 +68,7 @@ lower = defun "lower"
reverse :: DocumentedFunction e
reverse = defun "reverse"
### liftPure T.reverse
- <#> textParam "s"
+ <#> textParam "s" "UTF-8 string to revert"
=#> textResult "Reversed `s`"
#? "Reverses a string."
@@ -77,9 +76,9 @@ reverse = defun "reverse"
sub :: DocumentedFunction e
sub = defun "sub"
### liftPure3 substring
- <#> textParam "s"
+ <#> textParam "s" "UTF-8 string"
<#> textIndex "i" "substring start position"
- <#> textOptionalIndex "j" "substring end position"
+ <#> opt (textIndex "j" "substring end position")
=#> textResult "text substring"
#? "Returns a substring, using Lua's string indexing rules."
where
@@ -94,7 +93,7 @@ sub = defun "sub"
upper :: DocumentedFunction e
upper = defun "upper"
### liftPure T.toUpper
- <#> textParam "s"
+ <#> textParam "s" "UTF-8 string to convert to uppercase"
=#> textResult "Uppercase copy of `s`"
#? "Converts a string to upper case."
@@ -102,24 +101,8 @@ upper = defun "upper"
-- Parameters
--
-textParam :: Text -> Parameter e Text
-textParam name =
- parameter peekText "string" name "UTF-8 encoded string"
-
-textIndex :: Text -> Text -> Parameter e Int
-textIndex = parameter (peekIntegral @Int) "integer"
-
-textOptionalIndex :: Text -> Text -> Parameter e (Maybe Int)
-textOptionalIndex = optionalParameter (peekIntegral @Int) "integer"
-
---
--- Results
---
-
-textResult :: Text -- ^ Description
- -> FunctionResults e Text
-textResult = functionResult pushText "string"
-
-intResult :: Text -- ^ Description
- -> FunctionResults e Int
-intResult = functionResult (pushIntegral @Int) "integer"
+-- | String index parameter
+textIndex :: Text -- ^ parameter name
+ -> Text -- ^ parameter description
+ -> Parameter e Int
+textIndex = integralParam @Int
