packages feed

hsjuiz 0.4.0 → 0.5.0

raw patch · 4 files changed

+25/−10 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -3,6 +3,12 @@ hsjuiz の版は juiz(crates.io の juiz_app、PyPI の pyjuiz / juiz-cli)と同じ番号にそろえています。 使う libjuiz_sdk も同じ版にしてください。 +## 0.5.0++- 小数(`Double`・`Float`)の NaN・無限大を文字列 `"NaN"`・`"Infinity"`・`"-Infinity"` で読み書きするようにした+  (docs/spec/datatype.md §4.1、juiz#683)。API の形は 0.4.0 から変えていない。+- juiz 本体から qmp ブローカーを外した版(#659)に版をそろえた。+ ## 0.4.0  - hsjuiz の API は 0.3.7 から変えていない(ブローカーの C ABI 化と juiz broker install #634 の公開に版をそろえた)。
README.md view
@@ -352,7 +352,7 @@ `scripts/install-juiz-sdk.sh` で取得して `~/.juiz/sdk/<版>` に展開できます。  ```terminal-curl -fsSL https://raw.githubusercontent.com/OpenJUIZ/juiz/main/scripts/install-juiz-sdk.sh | sh -s -- 0.4.0+curl -fsSL https://raw.githubusercontent.com/OpenJUIZ/juiz/main/scripts/install-juiz-sdk.sh | sh -s -- 0.5.0 ```  それより前の版では、juiz のソースを同じ版のタグで取得し、`cargo build --release -p juiz_sdk` でできる `target/release` の libjuiz_sdk を使います。@@ -366,8 +366,8 @@ packages: .  package hsjuiz-  extra-lib-dirs: /home/me/.juiz/sdk/0.4.0/lib-  ghc-options: -optl-Wl,-rpath,/home/me/.juiz/sdk/0.4.0/lib+  extra-lib-dirs: /home/me/.juiz/sdk/0.5.0/lib+  ghc-options: -optl-Wl,-rpath,/home/me/.juiz/sdk/0.5.0/lib ```  ```terminal@@ -379,11 +379,11 @@ その `bindings/hsjuiz` を `cabal.project` の `packages:` に足します。  ```cabal-packages: . /home/me/juiz-0.4.0/bindings/hsjuiz+packages: . /home/me/juiz-0.5.0/bindings/hsjuiz ```  ```terminal-git clone --depth 1 --branch v0.4.0 https://github.com/OpenJUIZ/juiz.git /home/me/juiz-0.4.0+git clone --depth 1 --branch v0.5.0 https://github.com/OpenJUIZ/juiz.git /home/me/juiz-0.5.0 ```  juiz のリポジトリの中でビルドするときは、`cargo build` でできる `target/debug` の libjuiz_sdk を
hsjuiz.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               hsjuiz-version:            0.4.0+version:            0.5.0 synopsis:           Write juiz processes and containers in Haskell description:     Write Process / Container / Component plugins of
src/Juiz/Capsule.hs view
@@ -41,6 +41,7 @@ import Foreign.Ptr (FunPtr, Ptr, nullPtr) import Foreign.StablePtr (castStablePtrToPtr, freeStablePtr, newStablePtr) import Foreign.Storable (Storable, peek)+import GHC.Float (double2Float, float2Double)  import Juiz.Error import Juiz.Image@@ -117,18 +118,26 @@ instance FromCapsule Word32 where fromValue = boundedInt "Word32" instance ToCapsule Word32 where toValue = JInt . fromIntegral --- | 整数も小数として受け取る+-- | 整数も小数として受け取る。NaN・無限大は文字列 @"NaN"@・@"Infinity"@・@"-Infinity"@ で表す (datatype.md §4) instance FromCapsule Double where   fromValue (JFloat d) = Right d   fromValue (JInt i) = Right (fromIntegral i)   fromValue (JUInt w) = Right (fromIntegral w)+  fromValue (JString "NaN") = Right (0 / 0)+  fromValue (JString "Infinity") = Right (1 / 0)+  fromValue (JString "-Infinity") = Right (-1 / 0)   fromValue v = typeMismatch "Double" v-instance ToCapsule Double where toValue = JFloat+instance ToCapsule Double where+  toValue d+    | isNaN d = JString "NaN"+    | isInfinite d = JString (if d > 0 then "Infinity" else "-Infinity")+    | otherwise = JFloat d  -- | 整数も小数として受け取る (データ型の float)+-- realToFrac は最適化なしだと Rational を通って NaN・無限大が壊れるので float2Double / double2Float を使う instance FromCapsule Float where-  fromValue v = realToFrac <$> (fromValue v :: Either Text Double)-instance ToCapsule Float where toValue = JFloat . realToFrac+  fromValue v = double2Float <$> (fromValue v :: Either Text Double)+instance ToCapsule Float where toValue = toValue . float2Double  instance FromCapsule Text where   fromValue (JString t) = Right t