packages feed

no-recursion-0.3.0.0: no-recursion.cabal

cabal-version: 3.0

name: no-recursion
version: 0.3.0.0
synopsis: A GHC plugin to remove support for recursion
description: General recursion can be the cause of a lot of problems. This
             removes recursion from GHC, allowing you to guarantee you’re using
             other mechanisms, like recursion schemes.
author: Greg Pfeil <greg@technomadic.org>
maintainer: Greg Pfeil <greg@technomadic.org>
copyright: 2024 Greg Pfeil
homepage: https://github.com/sellout/no-recursion#readme
bug-reports: https://github.com/sellout/no-recursion/issues
category: Recursion
build-type: Custom
-- TODO: Remove the redundant `OR AGPL-3.0-only` once
--       haskell/hackage-server#1440 is fixed.
license: AGPL-3.0-only WITH Universal-FOSS-exception-1.0 OR AGPL-3.0-only OR LicenseRef-commercial
license-files:
  LICENSE
  LICENSE.AGPL-3.0-only
  LICENSE.Universal-FOSS-exception-1.0
  LICENSE.commercial
extra-doc-files:
  CHANGELOG.md
  README.md
  docs/*.md
tested-with:
  GHC == {
    9.6.1, 9.6.3,
    9.8.1, 9.8.4,
    9.10.1,
    9.12.1
  }

source-repository head
  type: git
  location: https://github.com/sellout/no-recursion.git
  subdir: core

flag noisy-deprecations
  description:
    Prior to GHC 9.10, the `DEPRECATED` pragma can’t distinguish between terms
    and types. Consenquently, you can get spurious warnings when there’s a name
    collision and the name in the other namespace is deprecated. Or you can
    choose to not get those warnings, at the risk of not being warned when
    there’s a name collision and the namespace you’re referencing is the one
    that’s deprecated.

custom-setup
  setup-depends:
    -- TODO: Due to haskell/cabal#3751, `Cabal` has to be specified even though
    --       there’s no direct dependency. Its lower bound needs to match
    --      `cabal-version` at the top of this file, and Hackage requires it to
    --       have _some_ upper bound. (Since there’s no direct dependency, it
    --       doesn’t use PVP bounds.)
    Cabal >= 3.0 && < 99,
    base ^>= {4.18.0, 4.19.0, 4.20.0, 4.21.0},
    cabal-doctest ^>= {1.0.0},

-- This mimics the GHC2024 extension
-- (https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/control.html?highlight=doandifthenelse#extension-GHC2024),
-- but supporting compilers back to GHC 8.0. If the oldest supported compiler
-- is GHC 9.10, then this stanza can be removed and `import: GHC2024` can be
-- replaced by `default-language: GHC2024`. If the oldest supported compiler is
-- GHC 9.2, then this can be simplified by setting `default-language: GHC2021`
-- and only including the extensions added by GHC2024.
common GHC2024
  default-language: GHC2021
  default-extensions:
    DataKinds
    DerivingStrategies
    DisambiguateRecordFields
    GADTs
    LambdaCase
    MagicHash
    MonadComprehensions
    RoleAnnotations

common defaults
  import: GHC2024
  build-depends:
    base ^>= {4.18.0, 4.19.0, 4.20.0, 4.21.0},
  ghc-options:
    -Weverything
    -- This one just reports unfixable things, AFAICT.
    -Wno-all-missed-specialisations
    -- Type inference good.
    -Wno-missing-local-signatures
    -Wno-prepositive-qualified-module
    -- Warns even when `Unsafe` is explicit, not inferred. See
    -- https://gitlab.haskell.org/ghc/ghc/-/issues/16689
    -Wno-unsafe
  if impl(ghc >= 9.8.1)
    ghc-options:
      -- Inference good.
      -Wno-missing-role-annotations
  default-extensions:
    BlockArguments
    DefaultSignatures
    ExplicitNamespaces
    FunctionalDependencies
    LexicalNegation
    LiberalTypeSynonyms
    PackageImports
    ParallelListComp
    QualifiedDo
    RecursiveDo
    -- RequiredTypeArguments - uncomment if the oldest supported version is GHC 9.10.1+
    StrictData
    TemplateHaskellQuotes
    TransformListComp
    NoGeneralizedNewtypeDeriving
    NoImplicitPrelude
    NoMonomorphismRestriction
    NoPatternGuards
    NoStarIsType
    NoTypeApplications
  if flag(noisy-deprecations)
    cpp-options: -DSELLOUT_NOISY_DEPRECATIONS

library
  import: defaults
  hs-source-dirs: src
  build-depends:
    ghc ^>= {9.6.1, 9.8.1, 9.10.1, 9.12.1},
  exposed-modules:
    NoRecursion
  other-modules:
    PluginUtils

test-suite doctests
  import: defaults
  type: exitcode-stdio-1.0
  hs-source-dirs: tests
  main-is: doctests.hs
  build-depends:
    doctest ^>= {0.21.1, 0.22.2, 0.24.0},
    no-recursion,
  -- TODO: The sections below here are necessary because we don’t have control
  --       over the generated `Build_doctests.hs` file. So we have to silence
  --       all of its warnings one way or another.
  ghc-options:
    -Wno-missing-deriving-strategies
    -Wno-missing-export-lists
    -Wno-missing-import-lists
    -Wno-missing-kind-signatures
    -Wno-safe
    -- `doctest` requires the package containing the doctests as a dependency
    -- to ensure it gets built before this test-suite, even though the package
    -- appears to be unused.
    -Wno-unused-packages
  default-extensions:
    -- Since we can’t add `{-# LANGUAGE Safe -#}` to the generated
    -- “Build_doctests.hs”, we set it here, and that means it has to match
    -- doctests.hs, which is `Unsafe`.
    Unsafe

test-suite annotations
  import: defaults
  type: exitcode-stdio-1.0
  build-depends:
    no-recursion,
  ghc-options:
    -fplugin NoRecursion
  hs-source-dirs: tests/ignore
  main-is: test.hs
  other-modules:
    Test.AllowRecursion
    Test.AnnModule
    Test.AnnName
    Test.IgnoreDefaultImpls
    Test.UnannName

test-suite no-ignore-annotations
  import: defaults
  type: exitcode-stdio-1.0
  build-depends:
    no-recursion,
  ghc-options:
    -fplugin NoRecursion
    -fplugin-opt NoRecursion:ignore-method-cycles:false
  hs-source-dirs: tests/no-ignore
  main-is: test.hs
  other-modules:
    Test.IgnoreDefaultImpls