Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • morley-framework/morley
  • michaeljklein/morley
  • zgrannan/morley
  • SuedeHead/morley
  • george-serokell/morley
  • Alphaskyoficial/morley
  • david.feuer/morley
  • astump97/morley
  • mavryk-network/morley
9 results
Select Git revision
Show changes
Commits on Source (3)
<!-- Unreleased: append new entries here -->
* [!1080](https://gitlab.com/morley-framework/morley/-/merge_requests/1080)
Add more `PrettyShow` type instances
+ For lists
+ Add instances that forbid defining `PrettyShow` for `String`, `Text`, and `ByteString`
* [!1075](https://gitlab.com/morley-framework/morley/-/merge_requests/1075)
Add suitable types for oddly-sized unsigned integers
+ Add a dependency on `OddWord`.
......
......@@ -17,6 +17,7 @@ import Data.Fixed (Fixed)
import Data.Time (NominalDiffTime)
import Data.Typeable (TypeRep)
import Data.Word.Odd (Word62, Word63)
import GHC.TypeLits (ErrorMessage(..), TypeError)
import Language.Haskell.Extension (KnownExtension)
import Language.Haskell.TH (Name)
import Language.Haskell.TH.PprLib (Doc)
......@@ -70,6 +71,37 @@ type instance PrettyShow TypeRep = ()
-- NominalDiffTime show instance is human-readable instead of machine-readable
type instance PrettyShow NominalDiffTime = ()
-- Lists are human-readable if each element in it is
type instance PrettyShow [a] = PrettyShow a
-- Show instances for String and similar types are not entirely human-readable.
-- For instance:
--
-- >>> print "A string with \"quotes\""
-- "A string with \"quotes\""
--
-- >>> print "A string with non-ascii characters हि"
-- "A string with non-ascii characters \2361\2367"
type instance PrettyShow Text = TypeError (
'Text "Show instance for Text is not pretty" ':$$:
'Text "Consider relying on the Buildable instance"
)
type instance PrettyShow LText = TypeError (
'Text "Show instance for lazy Text is not pretty" ':$$:
'Text "Consider relying on the Buildable instance"
)
type instance PrettyShow Char = TypeError (
'Text "Show instance for String and Char is not pretty" ':$$:
'Text "Consider relying on the Buildable instance"
)
type instance PrettyShow ByteString = TypeError (
'Text "Show instance for ByteString is not pretty"
)
type instance PrettyShow LByteString = TypeError (
'Text "Show instance for lazy ByteString is not pretty"
)
-- | A version of 'Universum.show' that requires the value to have a human-readable
-- 'Show' instance.
show :: forall b a. (PrettyShow a, Show a, IsString b) => a -> b
......