cabal-version:      3.0
name:               linear-base
version:            0.5.0
license:            MIT
license-file:       LICENSE
copyright:          (c) Tweag Holding and affiliates
maintainer:         arnaud.spiwack@tweag.io
author:             Tweag
homepage:           https://github.com/tweag/linear-base#README
synopsis:           Standard library for linear types.
description:        Please see README.md.
category:           Prelude
build-type:         Simple
extra-source-files:
    README.md
    CHANGELOG.md
    docs/DESIGN.md
    docs/USER_GUIDE.md

source-repository head
    type:     git
    location: https://github.com/tweag/linear-base

common build-opts
    ghc-options: -O2 -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wnoncanonical-monad-instances
                 -- Additional warnings we may consider adding:
                 -- * -Wredundant-constraints : would need deactivating in the modules which use Nat
common rts-opts-multithread
    ghc-options: -threaded -rtsopts "-with-rtsopts=-N"
common rts-opts-monothread-stats
    ghc-options: -rtsopts "-with-rtsopts=-T"

library
    import: build-opts
    hs-source-dirs:     src
    if impl(ghc >= 9.4.0)
        hs-source-dirs: src-version-changes/ghc94/after
    else
        hs-source-dirs: src-version-changes/ghc94/before
    if impl(ghc >= 9.6.0)
        hs-source-dirs: src-version-changes/ghc96/after
    else
        hs-source-dirs: src-version-changes/ghc96/before
    exposed-modules:
        Control.Monad.IO.Class.Linear
        Control.Functor.Linear
        Control.Functor.Linear.Internal.Class
        Control.Functor.Linear.Internal.Instances
        Control.Functor.Linear.Internal.Kan
        Control.Functor.Linear.Internal.MonadTrans
        Control.Functor.Linear.Internal.Reader
        Control.Functor.Linear.Internal.State
        Control.Optics.Linear
        Control.Optics.Linear.Internal
        Control.Optics.Linear.Iso
        Control.Optics.Linear.Lens
        Control.Optics.Linear.Prism
        Control.Optics.Linear.Traversal
        Data.Arity.Linear
        Data.Arity.Linear.Internal
        Data.Array.Destination
        Data.Array.Destination.Internal
        Data.Array.Mutable.Linear
        Data.Array.Mutable.Linear.Internal
        Data.Array.Mutable.Unlifted.Linear
        Data.Array.Polarized
        Data.Array.Polarized.Pull
        Data.Array.Polarized.Pull.Internal
        Data.Array.Polarized.Push
        Data.Bifunctor.Linear
        Data.Bifunctor.Linear.Internal.Bifunctor
        Data.Bifunctor.Linear.Internal.SymmetricMonoidal
        Data.Bool.Linear
        Data.Either.Linear
        Data.Functor.Linear
        Data.Functor.Linear.Internal.Functor
        Data.Functor.Linear.Internal.Applicative
        Data.Functor.Linear.Internal.Traversable
        Data.HashMap.Mutable.Linear
        Data.HashMap.Mutable.Linear.Internal
        Data.List.Linear
        Data.Maybe.Linear
        Data.Monoid.Linear
        Data.Monoid.Linear.Internal.Monoid
        Data.Monoid.Linear.Internal.Semigroup
        Data.Num.Linear
        Data.Ord.Linear
        Data.Ord.Linear.Internal.Ord
        Data.Ord.Linear.Internal.Eq
        Data.Profunctor.Kleisli.Linear
        Data.Profunctor.Linear
        Data.Set.Mutable.Linear
        Data.Set.Mutable.Linear.Internal
        Data.Tuple.Linear
        Data.Tuple.Linear.Compat
        Data.Unrestricted.Linear
        Data.Unrestricted.Linear.Internal.Consumable
        Data.Unrestricted.Linear.Internal.Dupable
        Data.Unrestricted.Linear.Internal.Movable
        Data.Unrestricted.Linear.Internal.Instances
        Data.Unrestricted.Linear.Internal.Ur
        Data.Unrestricted.Linear.Internal.UrT
        Data.Replicator.Linear
        Data.Replicator.Linear.Internal
        Data.Replicator.Linear.Internal.ReplicationStream
        Data.Replicator.Linear.Internal.Instances
        Data.V.Linear
        Data.V.Linear.Internal
        Data.V.Linear.Internal.Instances
        Data.Vector.Mutable.Linear
        Data.Vector.Mutable.Linear.Internal
        Debug.Trace.Linear
        Foreign.Marshal.Pure
        Foreign.Marshal.Pure.Internal
        Prelude.Linear
        Prelude.Linear.Generically
        Prelude.Linear.GenericUtil
        Prelude.Linear.Internal
        Prelude.Linear.Internal.Generically
        Prelude.Linear.Internal.TypeEq
        Prelude.Linear.Unsatisfiable
        Streaming.Linear
        Streaming.Linear.Internal.Consume
        Streaming.Linear.Internal.Interop
        Streaming.Linear.Internal.Many
        Streaming.Linear.Internal.Process
        Streaming.Linear.Internal.Produce
        Streaming.Linear.Internal.Type
        Streaming.Prelude.Linear
        System.IO.Linear
        System.IO.Resource.Linear
        System.IO.Resource.Linear.Internal
        Unsafe.Linear
    default-language: Haskell2010
    build-depends:
        base >=4.16 && <5,
        containers,
        ghc-prim,
        ghc-bignum,
        hashable,
        linear-generics >= 0.2,
        storable-tuple,
        text,
        transformers,
        vector >=0.12.2,
        primitive

library examples
    import: build-opts
    hs-source-dirs: examples
    exposed-modules:
        Foreign.List
        Foreign.Heap
        Simple.FileIO
        Simple.Pure
        Simple.Quicksort
        Simple.TopSort
    build-depends:
        base,
        linear-base,
        storable-tuple,
        vector,
        text
    default-language: Haskell2010

test-suite test
    import: build-opts
    import: rts-opts-multithread
    type:             exitcode-stdio-1.0
    main-is:          Main.hs
    hs-source-dirs:   test
    other-modules:
        Test.Data.Destination
        Test.Data.Functor.Linear
        Test.Data.List
        Test.Data.Mutable.Array
        Test.Data.Mutable.HashMap
        Test.Data.Mutable.Set
        Test.Data.Mutable.Vector
        Test.Data.Polarized
        Test.Data.Replicator
        Test.Data.V
    default-language: Haskell2010
    build-depends:
        inspection-testing,
        tasty-inspection-testing,
        base,
        linear-base,
        containers,
        hedgehog,
        tasty,
        tasty-hedgehog >= 1.2,
        mmorph,
        vector,
        linear-generics

test-suite test-examples
    import: build-opts
    import: rts-opts-multithread
    type:             exitcode-stdio-1.0
    main-is:          Main.hs
    hs-source-dirs:   test-examples
    other-modules:
        Test.Foreign
        Test.Simple.Quicksort
    default-language: Haskell2010
    build-depends:
        base,
        linear-base,
        tasty,
        tasty-hedgehog,
        hedgehog,
        examples

benchmark bench
    import: build-opts
    import: rts-opts-monothread-stats
    type:             exitcode-stdio-1.0
    main-is:          Main.hs
    hs-source-dirs:   bench
    other-modules:
        Data.Mutable.HashMap
        Data.Mutable.Array
        Data.Mutable.Quicksort
    default-language: Haskell2010
    build-depends:
        base,
        containers,
        vector,
        deepseq,
        hashtables,
        hashable,
        linear-base,
        random,
        random-shuffle,
        tasty-bench >= 0.3,
        unordered-containers,
        MonadRandom,
        examples