MIT licensed by Rick Owens
Maintained by [email protected]
This version can be pinned in stack with:om-show-0.1.2.13@sha256:b307d62c3f0c443c4e3f10c9d5790e1502be820cc22d398f5205b91cae1a7189,1037

Module documentation for 0.1.2.13

Depends on 3 packages(full list with versions):
Used by 3 packages in nightly-2026-06-26(full list with versions):

om-show

Haskell utilities for turning values into string representations. It is mainly just a couple of very useful functions that eliminate a lot of conversion to from text types. It’s so small that I can just post the entire source code in this README:

{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

{- | Utilities for showing string-like things. -}
module OM.Show (
  showt,
  showj,
  ShowJ(..),
) where


import Data.Aeson (encode, ToJSON)
import Data.String (IsString, fromString)
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Encoding as TLE


{- | Like 'show', but for any string-like thing. -}
showt :: (Show a, IsString b) => a -> b
showt = fromString . show


{- |
  Show the JSON representation as any kind of string-like thing.
  Primarily useful for dumping JSON values into log messages without having to
  jump through too many hoops.
-}
showj :: (ToJSON a, IsString b) => a -> b
showj = fromString . TL.unpack . TLE.decodeUtf8 . encode


{- |
  Wrapper whose 'Show' instance outputs JSON.

  Especially useful with `-XDerivingVia`
  e.g.

  > newtype Foo = Foo SomeType
  >   deriving Show via (ShowJ SomeType)

  This will cause @show (foo :: Foo) to output the JSON representation
  of SomeType.
-}
newtype ShowJ a = ShowJ a
  deriving stock (Eq, Ord)
  deriving newtype (ToJSON)
instance (ToJSON a) => Show (ShowJ a) where
  show = showj

Changes

Changelog

All notable changes to this project will be documented in this file.

[0.1.2.13] - 2026-06-26

Changed

  • Raised the aeson upper bound to < 2.4 for aeson 2.3 compatibility.

[0.1.2.12] - 2025-02-06

Added

  • Support for GHC 9.14.