himari
A standard library for Haskell as an alternative to rio
https://github.com/ncaq/himari
| Stackage Nightly 2026-06-18: | 1.1.6.0 |
| Latest on Hackage: | 1.1.6.0 |
himari-1.1.6.0@sha256:abd28f86f4d7728fdcf1c0272aeb9b2fd38b7cc0f7d47b25029f321156935091,5260Module documentation for 1.1.6.0
- Himari
- Himari.Char
- Himari.Env
- Himari.Logger
- Himari.Prelude
- Himari.Prelude.Aeson
- Himari.Prelude.Arrow
- Himari.Prelude.Casing
- Himari.Prelude.Catch
- Himari.Prelude.Category
- Himari.Prelude.Data
- Himari.Prelude.FilePath
- Himari.Prelude.Generics
- Himari.Prelude.Here
- Himari.Prelude.Monoid
- Himari.Prelude.Process
- Himari.Prelude.Safe
- Himari.Prelude.Type
- Himari.Prelude.TypeLevel
- Himari.Prelude.UUID
- Himari.SafePrelude
himari
A standard library for Haskell to replace rio
このプロジェクトは、 commercialhaskell/rio: A standard library for Haskell の思想を踏襲しつつ、 よりスムーズな開発が出来ることを目指した改良ライブラリです。
背景
私はrioの思想が好みで長く使っています。
しかしrioの好みではない点もいくつかあります。 単純に質の問題であれば私がコントリビュートすれば良いのですが、 非互換な選択である部分が多いため、 それは受け入れられないだろうと考えて、 rioに似たライブラリであるhimariを作成することにしました。
目標
依存関係が大きくなることを恐れない
例えばrioは依存関係を小さくしようと考えているのか、 lensではなく、 microlensを採用しています。
しかし実際のライブラリでは本家のlensに依存していることも多いです。 開発でも実際のlensを使いたいです。 その結果コンフリクトすることが多発します。
Haskellは静的にビルドする言語なので、 依存関係が多いことはあまり怖くありません。
ビルドした時に使わないデッドコードはコンパイラが勝手に消してくれます。
他にも使うとは限らない依存関係もドシドシimportしてしまいます。
バージョンごとの依存関係の解決が大変なのは、 Nixなどのパッケージマネージャのレイヤーで解決することにします。
なるべくimportを一行で済ませることを目指します
himariは基本的には以下の一行で代替Preludeを提供することを目指します。
import Himari
色々と書くのは面倒なので。 衝突しない範囲で大量にimportしてしまいます。
同じシンボル名をexportしていて衝突してしまうものは仕方がないので、 qualified importを使ってもらいます。
なるべく独自のシンボルを定義しない
himariはrioで言うRIO.Textのような独自のシンボルを定義することをなるべく避けます。
開発メンバーやコーディングエージェントに独自のシンボルを使うことを守ってもらうのが難しいからです。
しばしばオリジナルのシンボルをimportしてしまい、
コードレビューなどで手戻りが発生します。
ただしHimari.Preludeのサブモジュールは存在します。
Himari.Prelude.Aesonなどのシンボルです。
これはHaddockの制限により、
hidingを使ったre-exportはシンボルが全て展開されてしまうからです。
シンボルの展開が発生するとドキュメントが肥大化してしまいます。
サブモジュールでhidingを隠蔽することで、
Himari.Preludeのドキュメントをコンパクトに保っています。
これらのサブモジュールはHimari.Preludeから自動的にre-exportされるため、
rioのRIO.Textのように個別にimportする必要はありません。
ユーザから見ると直接扱う必要は基本的にないということです。
万が一誤ってサブモジュールを直接importした場合でも、
Himari.Preludeと重複importすることになり、
GHCが警告を出してくれるので、
気が付きやすいです。
セットアップ
himariを使うプロジェクトでは、 以下の設定ファイルをセットアップすることを強く推奨します。
hlint
himariは部分関数を除去する代わりに、
hlintで警告を出すことで対処しています。
プロジェクトルートにある.hlint.yamlファイルをコピーしてください。
既存の.hlint.yamlがある場合はマージしてください。
curl -L 'https://raw.githubusercontent.com/ncaq/himari/master/.hlint.yaml' -o '.hlint.yaml'
fourmolu
fourmoluはHaskellのフォーマッタです。 fourmoluは演算子の優先順位(fixity)を正しく解決するために、 カスタムPreludeがどのモジュールをre-exportしているかを知る必要があります。
プロジェクトルートにある、
fourmolu.yamlファイルの、
reexportsセクションをコピーしてください。
既存のfourmolu.yamlがある場合はreexportsセクションをマージしてください。
curl -L 'https://raw.githubusercontent.com/ncaq/himari/master/fourmolu.yaml' -o 'fourmolu.yaml'
[!NOTE] fourmolu.yamlにはhimari固有のフォーマット設定(indentation, column-limitなど)も含まれています。 素朴な設定ですが、プロジェクトに合わせて適宜変更してください。
AIエージェント向けのプラグイン
himariとAIエージェントを組み合わせて開発する時には、 ncaq/konoka: AI prompts, agents, and skills as loadable plugins. というマーケットプレイスで開発している、 haskell-tasukeプラグイン を利用することを強く推奨します。
セットアップ方法はリポジトリにあるREADMEを参照してください。
konokaリポジトリのREADMEに従ってマーケットプレイスを追加し、 その後haskell-tasukeプラグインのREADMEに従ってインストールしてください。
一般的なHaskellの開発にも役立つプラグインにしていますが、 特にhimariを利用するのにフィットするようになっています。
現在はClaude Codeでのみ動作確認をしています。
注意
[!IMPORTANT] himariはrioとは完全に同じように使えるわけではありません。 ここで主な注意点を挙げます。
重大なランタイムの非互換性
ログの出力先の変更
rioは基本的に標準出力にログを出力しますが、 himariはデフォルトのセットアップ手順に従うと標準エラー出力にログを出力します。
ログは標準エラー出力に出すべきだと考えているためです。
変更したい時は出力先をstderrからstdoutなどに変更することで簡単に変更可能です。
部分関数への対処方法の違い
rioは部分関数を独自のモジュールでexportして提供していますが、 himariはそのままオリジナルのモジュールを使う方針です。
よってhimariは部分関数を除去していません。
なのでhimariはhlintのルールで警告を出すことで対処しています。 詳細はセットアップを参照してください。
Nix
このプロジェクトは開発環境として、 haskell.nix を使用しています。
あくまで開発環境として利用しているだけなので、 himariを使うのにnixを利用する必要はありません。
nix flake showが失敗する場合
haskell.nixはIFD(Import From Derivation)を使用するため、
複数システムをサポートするflakeでnix flake showを実行すると、
異なるシステム向けのビルドを評価しようとして失敗することがあります。
これはhaskell.nixの既知の制限であり、 現在のところ完全な回避策はありません。
Changes
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Haskell Package Versioning Policy.
[Unreleased]
[1.1.6.0] - 2026-06-16
Added
- hlint rule to import
Data.Containers.ListUtilsqualified asL, matching the alias used forData.List
Changed
- Relax the lower bound of the
uuiddependency from>=1.3.16.1to>=1.3.11, the first version that provides all of the re-exported and hidden names
Removed
- Stop distributing
.hlint.yamlandfourmolu.yamlas Cabaldata-files, since downstream usage cannot be verified..hlint.yamlis kept underextra-source-filesonly because the test suite needs it
[1.1.5.0] - 2026-06-14
Added
casingpackage (>=0.1.4.1) as a dependency for identifier case conversionHimari.Prelude.Casing:Text.Casingre-exports from thecasingpackage (hiding the overly generaldropPrefix,toWords, andfromWordsto avoid name conflicts)herepackage (>=1.2.14) as a dependency for here documents and string interpolationHimari.Prelude.Here:Data.String.Herere-exports from theherepackage (hiding the overly generaliandtemplateto avoid name conflicts)uuidpackage (>=1.3.16.1) as a dependency for UUID values and their generationHimari.Prelude.UUID:Data.UUIDandData.UUID.V4re-exports from theuuidpackage (hiding the overly general:null,toString,fromString,toText,fromText,fromWords,toWords, to avoid name conflicts)
[1.1.4.1] - 2026-06-13
Changed
- Widen the
containersversion bound from<0.8to<0.9to allowcontainers0.8, which ships with GHC 9.14. - Switch dependency version bounds from the PVP caret operator (
^>=) to explicit>=x && <yranges. So that Renovate can recognize and update them.
[1.1.4.0] - 2026-06-13
Added
discardLogActionexport inHimari.Logger, aLogActionthat discards all log output, useful for tests that should not write logs to the real terminalrunSimpleNoLogEnvexport inHimari.Env.Simple, a shorthand forrunSimpleEnvWith discardLogActionthat runs aSimpleEnvaction while discarding all log output- Re-export all public
timemodules thatData.Timeitself does not re-export inHimari.SafePrelude:Data.Time.Calendar.Easter,Data.Time.Calendar.Julian,Data.Time.Calendar.MonthDay,Data.Time.Calendar.Month,Data.Time.Calendar.OrdinalDate,Data.Time.Calendar.Quarter,Data.Time.Calendar.WeekDate,Data.Time.Clock.POSIX,Data.Time.Clock.System,Data.Time.Clock.TAI,Data.Time.Format.ISO8601, and register them in thefourmolu.yamlreexportssetting
Changed
- Relax
aesondependency upper bound from^>=2.2.3.0to^>=2.2.3.0 || ^>=2.3.0.0to allow building againstaeson2.3.y.z
Fixed
- Restructure the
fourmolu.yamlreexportschain to match the module hierarchy introduced withHimari.SafePreludein 1.1.3.0: re-exports that moved toHimari.SafePreludeare now registered under it instead ofHimari.Prelude, and the previously missingData.DefaultandUnliftIO.Retryentries are added
[1.1.3.0] - 2026-05-30
Added
Himari.SafePrelude, a Safe Haskell-compatible subset ofHimari.Preludere-exported byHimari.Prelude, so downstreamSafemodules canimport Himari.SafePreludedirectly without dragging in unsafe re-exports
Changed
- Relax
data-defaultdependency lower bound from^>=0.8.0.2to^>=0.8.0.0to widen the range of compatibledata-default0.8.x releases - Remove
DerivingViaandTemplateHaskellfromdefault-extensionsand enable them only in modules that use them, soSafemodules no longer needNoDerivingViaandNoTemplateHaskelloverrides - Promote
Himari.CharandHimari.LoggerfromTrustworthytoSafeby switching them to importHimari.SafePreludeinstead ofHimari.Prelude
[1.1.2.2] - 2026-05-28
Changed
- Relax
timedependency upper bound from^>=1.12.2to>=1.12.2 && <2to allow building against futuretime1.x releases - Declare
hlint ^>=3.10asbuild-tool-dependsfor the test suite socabal testno longer requireshlintto be pre-installed onPATH - Constrain
ghc-lib-parser >=9.12.3for the test suite under GHC>=9.12.3to avoid an unbuildable install plan withghc-lib-parser-9.12.2(which fails on GHC>=9.12.3becauseGHC.Internal.TH.Pprwas removed). See https://github.com/digital-asset/ghc-lib/issues/624 and https://github.com/ndmitchell/hlint/pull/1696
[1.1.2.1] - 2026-05-25
Added
- GHC 9.12.3 and 9.12.4 support
[1.1.2.0] - 2026-05-25
Added
mkSimpleEnvexport inHimari.Env.Simpleto construct aSimpleEnvwith the default settings separately from running itdefaultMonadLoggerLogexport inHimari.Logger, a reusablemonadLoggerLogimplementation for anyHasLogActionenvironmentdefaultLogActionexport inHimari.Loggerfor the defaultLogActionthat writes to standard error- Safe Haskell annotations.
Modules that expose only safe APIs and import only safe modules are marked
Safe; they disableTemplateHaskell,DerivingVia, andGeneralizedNewtypeDeriving, which are enabled globally but not allowed under Safe Haskell. Modules that expose only safe APIs but cannot be inferredSafe(because a dependency is not marked safe, or because they use Template Haskell orGeneralizedNewtypeDerivinginternally) are markedTrustworthy.
[1.1.1.0] - 2026-05-24
Added
Numericre-export inHimari.Preludefor extra numeric functions- HLint rules to warn against partial functions re-exported from
Numeric:showIntAtBase,showInt,showHex,showOct, andshowBin, which throw on negative (or invalid base) input
[1.1.0.0] - 2026-04-11
Added
- GHC 9.14.1 support
Changed
- Relax
sydtestdependency upper bound from<0.19to<0.24to support nixpkgs sydtest 0.20.0.1+
Removed
- Drop Intel Mac (x86_64-darwin) from Nix build targets due to Nix ending support for this platform
[1.0.5.0] - 2026-01-12
Added
data-defaultpackage (^>=0.8.0.2) as a dependency for default value supportData.Defaultre-export inHimari.PreludeforDefaulttype class anddeffunctionretrypackage (^>=0.9.3.1) as a dependency for retry combinatorsUnliftIO.Retryre-export inHimari.Preludefor retry operations with exponential backoff- HLint rules to warn against dangerous language extensions:
AllowAmbiguousTypes,DeferTypeErrors,ExtendedDefaultRules,ImpredicativeTypes,IncoherentInstances,LiberalTypeSynonyms,OverlappingInstances,RebindableSyntax,UndecidableSuperClasses - HLint rules to warn against discouraged language extensions:
ImplicitParams,UndecidableInstances
Changed
- Document recommended language extensions beyond GHC2024
(e.g.,
BlockArguments,NoFieldSelectors,OverloadedStrings,StrictData, etc.) with rationale for each - Document extensions intentionally not enabled
(e.g.,
Arrows,DeriveAnyClass,OverloadedLists,OverloadedRecordUpdate,Strict,UnicodeSyntax) with reasons - Document dangerous language extensions that should be avoided:
AllowAmbiguousTypes,DeferTypeErrors,ExtendedDefaultRules,ImpredicativeTypes,IncoherentInstances,LiberalTypeSynonyms,OverlappingInstances,RebindableSyntax,UndecidableSuperClasses - Document discouraged language extensions that require caution:
ImplicitParams,UndecidableInstances
[1.0.4.0] - 2026-01-09
Added
UnliftIO.Concurrentre-export inHimari.Preludefor lifted concurrent operationsUnliftIO.Directoryre-export inHimari.Preludefor lifted directory operationsUnliftIO.Environmentre-export inHimari.Preludefor lifted environment operationsUnliftIO.Exception.Lensre-export inHimari.Preludefor lens-based exception handlingUnliftIO.Foreignis not re-exported to avoidwithArrayconflict withData.AesonUnliftIO.IO.Filere-export inHimari.Preludefor atomic/durable file operations- HLint rules: prefer
UnliftIO.ConcurrentoverControl.Concurrent - HLint rules: prefer
UnliftIO.EnvironmentoverSystem.Environment - HLint rules: prefer
UnliftIO.Exception.LensoverControl.Exception.Lens - HLint rule: restrict
forkOnWithUnmask(exceptions don’t propagate to parent thread)
Changed
System.Process.TypedhidingsetEnvto preferUnliftIO.Environment.setEnvSystem.Process.Typedis now re-exported viaHimari.Prelude.Processinstead of directly
[1.0.3.2] - 2026-01-08
Changed
- Fix HLint language extension configuration: use
argumentswith-Xflags for parsing instead ofextensionsblock (which is for restricting allowed extensions) - Rename
hlint/rules/extensions.dhalltohlint/rules/parse-extensions.dhall - Remove
TemplateHaskellfrom parse extensions (already enabled by default in HLint)
[1.0.3.1] - 2026-01-08
Added
- HLint language extension support in Dhall configuration
- Default language extensions for parsing:
QuasiQuotes,CPP,RecursiveDo,OverloadedRecordDot,OverloadedRecordUpdate,TemplateHaskell,BlockArguments ExtensionItemtype and helper functions (extensionNames,extensionNamesWithin,extensions) inhlint/Builder.dhallhlint/rules/extensions.dhallfor managing default enabled extensions
[1.0.3.0] - 2026-01-08
Added
GHC.Stackre-export inHimari.Preludefor call stack support (HasCallStack, etc.)- HLint rule for
errorWithStackTrace(deprecated function warning)
[1.0.2.0] - 2026-01-07
Added
Himari.Prelude.Arrow:Control.Arrowre-exports (hiding conflicting symbols)Himari.Prelude.Catch:Control.Monad.Catchre-exports (hiding UnliftIO conflicts)Himari.Prelude.Data:Data.Datare-exports (hiding GHC.Generics conflicts)Himari.Prelude.Monoid:Data.Monoid/Data.Semigroupre-exports (hiding conflicts)Himari.Prelude.TypeLevel: type-level programming (Data.Type.Coercion,Data.Type.Equality)Himari.Prelude.FunctorSpec: test module for functor-related exportsControl.Arrowre-export inHimari.Prelude(viaHimari.Prelude.Arrow)Data.Coercere-export inHimari.Preludefor safe type coercionData.Complexre-export inHimari.Preludefor complex number supportData.Datare-export inHimari.Prelude(viaHimari.Prelude.Data) for generic programmingData.Fixedre-export inHimari.Preludefor fixed-point arithmeticData.Functor.Composere-export inHimari.Preludefor functor compositionData.Intre-export inHimari.Preludefor sized integer typesData.Kindre-export inHimari.Preludefor kind-level types (Type,Constraint)Data.Monoid/Data.Semigroupre-export inHimari.Prelude(viaHimari.Prelude.Monoid)Data.Proxyre-export inHimari.Preludefor type-level proxy valuesData.Type.Coercion/Data.Type.Equalityre-export (viaHimari.Prelude.TypeLevel)Numeric.Naturalre-export inHimari.Preludefor non-negative integers
Changed
Himari.Prelude.Aeson: Hide overly general symbolsHimari.Prelude.Catch: HideHandlerto avoid conflicts
[1.0.1.0] - 2026-01-06
Added
- Added
Magnifyinstance forHimarimonad - Bundle
fourmolu.yamlin Cabaldata-filesso downstream users can reuse the formatter config - Add
fourmolu.yamlreexports and fixity settings to resolve operator precedence - Document setup steps in README for copying/merging
.hlint.yamlandfourmolu.yaml - Add fourmolu customization notes to README
[1.0.0.2] - 2026-01-03
Added
- Support for Windows
- Support for macOS (x86_64-darwin, aarch64-darwin) and Linux ARM (aarch64-linux)
Himari.Prelude.Aesonmodule for JSON-related re-exportsHimari.Prelude.Safemodule for safe function re-exportsHimari.Prelude.Categorymodule forControl.Categoryre-exports (hidingidand.)Himari.Prelude.Genericsmodule forGHC.Genericsre-exports (hidingfromandto)Himari.Prelude.FilePathmodule forSystem.FilePathre-exports (hiding<.>)Himari.Prelude.Typemodule for type-only re-exports (ByteString,Text,Map, etc.)
Changed
- Refactor
Himari.Preludeto use submodules for cleaner Haddock documentation
[1.0.0.1] - 2026-01-01
Changed
- Move
-joption fromhimari.cabalghc-options tocabal.projectto fix Hackage upload compatibility
[1.0.0.0] - 2026-01-01
Added
Himarimodule that re-exports all submodulesHimari.Preludemodule as a custom PreludeHimari.Charmodule withdigitToIntMay,intToDigitMay,chrMayHimari.Envmodule withHimarinewtype,runHimari,liftHimari,mapHimariHimari.Env.Simplemodule withSimpleEnv,runSimpleEnv,runSimpleEnvWithHimari.Loggermodule withHasLogActiontype class andLogActiontype alias- Re-exports from
Control.Lens,Control.Monad.*,Data.*,UnliftIOin Prelude - Re-exports from
safe,aeson,pretty-simple,monad-logger,typed-processin Prelude - Common type exports:
ByteString,Text,Vector,Map,HashMap, etc. - Bundled
.hlint.yamlasdata-fileswith comprehensive rules managed in Dhall - HLint rules for partial function warnings in base, containers, text, bytestring, vector
- HLint rules for unsafe function warnings in primitive, UnliftIO
- HLint rules preferring UnliftIO over base IO modules
- HLint rules preferring typed-process over System.Process
- HLint rules preferring
convertfrom convertible - HLint rules preferring
pTrace*overDebug.Trace - HLint rules for qualified import naming conventions
- HLint rules for aeson, lens, mtl, yaml, and more
- Support for GHC 9.10.2, 9.10.3, and 9.12.2
- GHC2024 as the default language with
NoImplicitPreludeextension