packages feed

unwitch-2.0.0: unwitch.cabal

cabal-version:      3.0

name:           unwitch
version:        2.0.0
homepage:       https://github.com/jappeace/unwitch#readme
synopsis:  converts between primitives
description: 
  Removes the magic from witch.
  This provides safe conversions like witch does.
  But it [doesn't](https://jappie.me/death-to-type-classes.html) use [type classes](https://www.haskellforall.com/2012/05/scrap-your-type-classes.html)
  or exceptions.
  This has a couple of advantages:

  1. No need to use type application for function selection.
  2. Functions get names that describe what they do.
    This allows ctags to work as well.
  3. No trouble with orphans.
  4. Custom errors instead of the prelude based ones allow client
    code to recover with typesafety even on partial conversions.
bug-reports:    https://github.com/jappeace/unwitch/issues
author:         Jappie Klooster
maintainer:     jappieklooster@hotmail.com
copyright:      2026 Jappie Klooster
license:        MIT
category: Data
license-file:   LICENSE
build-type:     Simple
extra-source-files:
    Readme.md
    LICENSE
extra-doc-files:
    Changelog.md

source-repository head
  type: git
  location: https://github.com/jappeace/unwitch

common common-options
  default-extensions:
      EmptyCase
      FlexibleContexts
      FlexibleInstances
      InstanceSigs
      MultiParamTypeClasses
      LambdaCase
      MultiWayIf
      NamedFieldPuns
      TupleSections
      DeriveFoldable
      DeriveFunctor
      DeriveGeneric
      DeriveLift
      DeriveTraversable
      DerivingStrategies
      GeneralizedNewtypeDeriving
      StandaloneDeriving
      OverloadedStrings
      TypeApplications
      NumericUnderscores
      ImportQualifiedPost
      UnboxedSums
      UnboxedTuples
      MagicHash

  ghc-options:
    -Wall -Wincomplete-uni-patterns
    -Wincomplete-record-updates -Widentities -Wredundant-constraints
    -Wcpp-undef -fwarn-tabs -Wpartial-fields
    -fdefer-diagnostics -Wunused-packages
    -fenable-th-splice-warnings
    -fno-omit-yields

  build-depends:
      base >=4.18.0.0 && <4.23,
      ghc-bignum < 2,
      bytestring >= 0.10 && < 0.13,
      text >= 1.2 && < 2.2

  default-language: Haskell2010

library
  import: common-options
  exposed-modules:
      Unwitch.Convert.ByteString
      Unwitch.Convert.Char
      Unwitch.Convert.Double
      Unwitch.Convert.Fixed
      Unwitch.Convert.Float
      Unwitch.Convert.Int
      Unwitch.Convert.Int8
      Unwitch.Convert.Int16
      Unwitch.Convert.Int32
      Unwitch.Convert.Int64
      Unwitch.Convert.Integer
      Unwitch.Convert.LazyByteString
      Unwitch.Convert.LazyText
      Unwitch.Convert.Natural
      Unwitch.Convert.Ratio
      Unwitch.Convert.ShortByteString
      Unwitch.Convert.Text
      Unwitch.Convert.Word
      Unwitch.Convert.Word8
      Unwitch.Convert.Word16
      Unwitch.Convert.Word32
      Unwitch.Convert.Word64
      Unwitch.Errors
  other-modules:
      Unwitch
      Unwitch.Constant
      Unwitch.TryEvaluate
  hs-source-dirs:
      src

test-suite unit
  import: common-options
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  ghc-options: -threaded -rtsopts "-with-rtsopts=-N" -Wno-unused-packages
  other-modules:
      Test.Convert.ByteStringSpec
      Test.Convert.Int8Spec
      Test.Convert.Int16Spec
      Test.Convert.Int32Spec
      Test.Convert.Int64Spec
      Test.Convert.IntSpec
      Test.Convert.LazyByteStringSpec
      Test.Convert.LazyTextSpec
      Test.Convert.Word8Spec
      Test.Convert.Word16Spec
      Test.Convert.Word32Spec
      Test.Convert.Word64Spec
      Test.Convert.WordSpec
      Test.Convert.NaturalSpec
      Test.Convert.IntegerSpec
      Test.Convert.FloatSpec
      Test.Convert.DoubleSpec
      Test.Convert.PropertySpec
      Test.Convert.RatioSpec
      Test.Convert.FixedSpec
      Test.Convert.CharSpec
      Test.Convert.ShortByteStringSpec
      Test.Convert.TextSpec
      Test.Convert.UnboxedSpec
  hs-source-dirs:
      test
  build-depends:
      hspec,
      hspec-core,
      unwitch