packages feed

himari 1.0.0.2 → 1.0.1.0

raw patch · 8 files changed

+184/−8 lines, 8 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Himari.Env: instance Control.Lens.Zoom.Magnify (Himari.Env.Himari s) (Himari.Env.Himari t) s t

Files

CHANGELOG.md view
@@ -7,6 +7,16 @@  ## [Unreleased] +## [1.0.1.0] - 2026-01-06++### Added++- Added `Magnify` instance for `Himari` monad+- Bundle `fourmolu.yaml` in Cabal `data-files` so downstream users can reuse the formatter config+- Add `fourmolu.yaml` reexports and fixity settings to resolve operator precedence for Himari’s Prelude+- Document setup steps in README for copying/merging `.hlint.yaml` and `fourmolu.yaml`+- Add fourmolu customization notes to README+ ## [1.0.0.2] - 2026-01-03  ### Added
README.md view
@@ -38,13 +38,40 @@ よってhimariは部分関数を除去していません。  なのでhimariはhlintのルールで警告を出すことで対処しています。+詳細は[セットアップ](#セットアップ)を参照してください。 -プロジェクトルートにある[.hlint.yaml](./.hlint.yaml)ファイルを、-以下のような方法であなたのプロジェクトにコピーしてください。+## セットアップ +himariを使うプロジェクトでは、+以下の設定ファイルをコピーすることを強く推奨します。++### hlint++himariは部分関数を除去する代わりに、+hlintで警告を出すことで対処しています。+プロジェクトルートにある[.hlint.yaml](./.hlint.yaml)ファイルをコピーしてください。+既存の`hlint.yaml`がある場合はマージしてください。+ ```console curl -L 'https://raw.githubusercontent.com/ncaq/himari/master/.hlint.yaml' -o '.hlint.yaml' ```++### fourmolu++[fourmolu](https://github.com/fourmolu/fourmolu)はHaskellのフォーマッタです。+fourmoluは演算子の優先順位(fixity)を正しく解決するために、+カスタムPreludeがどのモジュールをre-exportしているかを知る必要があります。++プロジェクトルートにある[fourmolu.yaml](./fourmolu.yaml)ファイルの`reexports`セクションをコピーしてください。+既存の`fourmolu.yaml`がある場合は`reexports`セクションをマージしてください。++```console+curl -L 'https://raw.githubusercontent.com/ncaq/himari/master/fourmolu.yaml' -o 'fourmolu.yaml'+```++> [!NOTE]+> fourmolu.yamlにはhimari固有のフォーマット設定(indentation, column-limitなど)も含まれています。+> 素朴な設定ですが、プロジェクトに合わせて適宜変更してください。  ## 背景 
+ fourmolu.yaml view
@@ -0,0 +1,114 @@+indentation: 2+column-limit: 120+function-arrows: leading+import-export-style: leading+haddock-style: single-line+sort-constraints: true+sort-derived-classes: true++# Himariがre-exportしているモジュールの演算子fixity解決用+# チェーン方式: fourmoluは再帰的にreexportsを展開する+reexports:+  # Himari → 内部モジュール+  - module Himari exports "himari" Himari.Char+  - module Himari exports "himari" Himari.Env+  - module Himari exports "himari" Himari.Env.Simple+  - module Himari exports "himari" Himari.Logger+  - module Himari exports "himari" Himari.Prelude++  # Himari.Prelude → 外部モジュール+  - module Himari.Prelude exports "base" Control.Applicative+  - module Himari.Prelude exports "base" Control.Monad+  - module Himari.Prelude exports "base" Control.Monad.ST+  - module Himari.Prelude exports "base" Data.Bifoldable+  - module Himari.Prelude exports "base" Data.Bifunctor+  - module Himari.Prelude exports "base" Data.Bitraversable+  - module Himari.Prelude exports "base" Data.Bool+  - module Himari.Prelude exports "base" Data.Either+  - module Himari.Prelude exports "base" Data.Eq+  - module Himari.Prelude exports "base" Data.Foldable+  - module Himari.Prelude exports "base" Data.Function+  - module Himari.Prelude exports "base" Data.Maybe+  - module Himari.Prelude exports "base" Data.Monoid+  - module Himari.Prelude exports "base" Data.Ord+  - module Himari.Prelude exports "base" Data.Ratio+  - module Himari.Prelude exports "base" Data.String+  - module Himari.Prelude exports "base" Data.Traversable+  - module Himari.Prelude exports "base" Data.Tuple+  - module Himari.Prelude exports "base" Data.Void+  - module Himari.Prelude exports "base" Data.Word+  - module Himari.Prelude exports "base" Prelude+  - module Himari.Prelude exports "base" Text.Show+  - module Himari.Prelude exports "convertible" Data.Convertible+  - module Himari.Prelude exports "deepseq" Control.DeepSeq+  - module Himari.Prelude exports "hashable" Data.Hashable+  - module Himari.Prelude exports "lens" Control.Lens+  - module Himari.Prelude exports "monad-logger" Control.Monad.Logger+  - module Himari.Prelude exports "mtl" Control.Monad.Cont+  - module Himari.Prelude exports "mtl" Control.Monad.Reader+  - module Himari.Prelude exports "mtl" Control.Monad.State.Strict+  - module Himari.Prelude exports "mtl" Control.Monad.Writer.CPS+  - module Himari.Prelude exports "pretty-simple" Debug.Pretty.Simple+  - module Himari.Prelude exports "pretty-simple" Text.Pretty.Simple+  - module Himari.Prelude exports "primitive" Control.Monad.Primitive+  - module Himari.Prelude exports "time" Data.Time+  - module Himari.Prelude exports "typed-process" System.Process.Typed+  - module Himari.Prelude exports "unliftio" UnliftIO+  # Himari.Prelude → 内部サブモジュール+  - module Himari.Prelude exports "himari" Himari.Prelude.Aeson+  - module Himari.Prelude exports "himari" Himari.Prelude.Category+  - module Himari.Prelude exports "himari" Himari.Prelude.FilePath+  - module Himari.Prelude exports "himari" Himari.Prelude.Generics+  - module Himari.Prelude exports "himari" Himari.Prelude.Safe+  - module Himari.Prelude exports "himari" Himari.Prelude.Type++  # Himari.Prelude.Aeson → 外部モジュール+  - module Himari.Prelude.Aeson exports "aeson" Data.Aeson+  - module Himari.Prelude.Aeson exports "aeson" Data.Aeson.QQ.Simple+  - module Himari.Prelude.Aeson exports "aeson-pretty" Data.Aeson.Encode.Pretty+  - module Himari.Prelude.Aeson exports "deriving-aeson" Deriving.Aeson++  # Himari.Prelude.Category → 外部モジュール+  - module Himari.Prelude.Category exports "base" Control.Category++  # Himari.Prelude.FilePath → 外部モジュール+  - module Himari.Prelude.FilePath exports "filepath" System.FilePath++  # Himari.Prelude.Generics → 外部モジュール+  - module Himari.Prelude.Generics exports "base" GHC.Generics++  # Himari.Prelude.Safe → 外部モジュール+  - module Himari.Prelude.Safe exports "safe" Safe+  - module Himari.Prelude.Safe exports "safe" Safe.Exact+  - module Himari.Prelude.Safe exports "safe" Safe.Foldable++  # Himari.Prelude.Type → 外部モジュール+  - module Himari.Prelude.Type exports "exceptions" Control.Monad.Catch+  - module Himari.Prelude.Type exports "bytestring" Data.ByteString+  - module Himari.Prelude.Type exports "bytestring" Data.ByteString.Lazy+  - module Himari.Prelude.Type exports "bytestring" Data.ByteString.Short+  - module Himari.Prelude.Type exports "unordered-containers" Data.HashMap.Strict+  - module Himari.Prelude.Type exports "unordered-containers" Data.HashSet+  - module Himari.Prelude.Type exports "containers" Data.IntMap.Strict+  - module Himari.Prelude.Type exports "containers" Data.IntSet+  - module Himari.Prelude.Type exports "base" Data.List+  - module Himari.Prelude.Type exports "base" Data.List.NonEmpty+  - module Himari.Prelude.Type exports "containers" Data.Map.Strict+  - module Himari.Prelude.Type exports "containers" Data.Sequence+  - module Himari.Prelude.Type exports "containers" Data.Set+  - module Himari.Prelude.Type exports "text" Data.Text+  - module Himari.Prelude.Type exports "text" Data.Text.Lazy+  - module Himari.Prelude.Type exports "containers" Data.Tree+  - module Himari.Prelude.Type exports "vector" Data.Vector++# 利用者向けの汎用的なfixity設定+# hspecは既にfourmoluによってサポートされているため不要+# sydtestは既にinfix宣言があるため不要+# sandwichはinfix宣言がないため手動設定が必要+# hspec, sydtest, sandwichと名前が被っている演算子が多いが優先度は概ね同じなので使いまわします+fixities:+  - infix 1 `shouldBe`, `shouldNotBe`, `shouldContain`, `shouldNotContain`+  - infix 1 `shouldBeSet`, `shouldContainPredicate`, `shouldNotContainPredicate`+  - infix 1 `shouldBeNothing`, `shouldBeJust`, `shouldBeLeft`, `shouldBeRight`+  - infix 1 `textShouldContain`, `textShouldNotContain`+  - infix 1 `shouldFail`, `shouldFailPredicate`, `shouldThrow`
himari.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: himari-version: 1.0.0.2+version: 1.0.1.0 synopsis: A standard library for Haskell as an alternative to rio description:   A standard library for Haskell inspired by rio.@@ -18,7 +18,10 @@ copyright: ncaq category: Control build-type: Simple-data-files: .hlint.yaml+data-files:+  .hlint.yaml+  fourmolu.yaml+ extra-doc-files:   CHANGELOG.md   README.md
src/Himari/Env.hs view
@@ -8,6 +8,7 @@   , mapHimari   ) where +import Control.Lens.Internal.Zoom (Effect) -- 直接の`UndecidableInstances`を避けるためにInternalを受け入れる。 import Himari.Prelude  -- | The Reader + IO monad.@@ -26,6 +27,11 @@ instance PrimMonad (Himari env) where   type PrimState (Himari env) = PrimState IO   primitive = Himari . ReaderT . const . primitive++type instance Magnified (Himari e) = Effect IO++instance Magnify (Himari s) (Himari t) s t where+  magnify l (Himari m) = Himari $ magnify l m  -- | Given an environment, runs the action that requires it in IO. runHimari :: (MonadIO m) => env -> Himari env a -> m a
test/Himari/Env/SimpleSpec.hs view
@@ -90,3 +90,19 @@         $(logInfo) "computing result"         pure (10 + 32 :: Int)       result `shouldBe` 42++  describe "Magnify instance" $ do+    it "works with magnify to access a sub-environment" $ do+      let+        -- 小さな環境 (Text) を要求するアクション+        subAction :: Himari Text Text+        subAction = do+          env <- ask+          pure $ env <> " world"+        -- 大きな環境 (Int, Text)+        bigEnv :: (Int, Text)+        bigEnv = (100, "hello")+      -- (Int, Text) の環境下で、_2 レンズを使って Text にズームして実行+      -- これがコンパイル・実行できれば Effect IO へのマッピングは成功している+      result <- runHimari bigEnv $ magnify _2 subAction+      result `shouldBe` "hello world"
test/HlintBaseSpec.hs view
@@ -30,8 +30,8 @@ runHlintOnSample :: IO Text runHlintOnSample = do   (exitCode, stdoutOutput, stderrOutput) <--    readProcess-      $ proc "hlint" ["test/HlintSamples/BasePartial.hs"]+    readProcess $+      proc "hlint" ["test/HlintSamples/BasePartial.hs"]   pure $ case exitCode of     ExitSuccess -> convert stdoutOutput     ExitFailure _ -> convert stdoutOutput <> convert stderrOutput
test/HlintUnliftioSpec.hs view
@@ -33,8 +33,8 @@ runHlintOnSample :: IO Text runHlintOnSample = do   (exitCode, stdoutOutput, stderrOutput) <--    readProcess-      $ proc "hlint" ["test/HlintSamples/UnliftioPreference.hs"]+    readProcess $+      proc "hlint" ["test/HlintSamples/UnliftioPreference.hs"]   pure $ case exitCode of     ExitSuccess -> convert stdoutOutput     ExitFailure _ -> convert stdoutOutput <> convert stderrOutput