Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.d/20260713_153000_effectfn_ffi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Changed

- `say` and `Lua.Ngx.Http.Status.set` are backed by `EffectFn1` foreigns
(`sayImpl`, `setImpl`) behind thin public wrappers; the public API is
unchanged. A saturated `say s` / `set st` in compiled code is now a single
direct Lua call with no per-call thunk allocation (previously two calls
and a fresh closure per invocation).
2 changes: 1 addition & 1 deletion src/Lua/Ngx.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return {say = (function(msg) return function() ngx.say(msg) end end)}
return {sayImpl = (function(msg) ngx.say(msg) end)}
5 changes: 4 additions & 1 deletion src/Lua/Ngx.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module Lua.Ngx where

import Data.Unit (Unit)
import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1)

foreign import say :: String -> Effect Unit
foreign import sayImpl :: EffectFn1 String Unit

say :: String -> Effect Unit
say = runEffectFn1 sayImpl
2 changes: 1 addition & 1 deletion src/Lua/Ngx/Http/Status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ return {
versionNotSupported = (ngx.HTTP_VERSION_NOT_SUPPORTED),
insufficientStorage = (ngx.HTTP_INSUFFICIENT_STORAGE),
get = (function() return ngx.status end),
set = (function(status) return function() ngx.status = status end end)
setImpl = (function(status) ngx.status = status end)
}
7 changes: 6 additions & 1 deletion src/Lua/Ngx/Http/Status.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Lua.Ngx.Http.Status where

import Data.Unit (Unit)
import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1)

foreign import data Status :: Type

Expand Down Expand Up @@ -42,5 +43,9 @@ foreign import gatewayTimeout :: Status
foreign import versionNotSupported :: Status
foreign import insufficientStorage :: Status

foreign import set :: Status -> Effect Unit
foreign import setImpl :: EffectFn1 Status Unit

set :: Status -> Effect Unit
set = runEffectFn1 setImpl

foreign import get :: Effect Status