@hackage no-recursion0.1.2.0

A GHC plugin to remove support for recursion

  • Deprecated

    @hackage/no-recursion-0.1.2.2
  • Tested Compilers

  • Dependencies (3)

    • base ^>=4.8.2 || ^>=4.9.1 || ^>=4.10.1 || ^>=4.11.0 || ^>=4.12.0 || ^>=4.13.0 || ^>=4.14.0 || ^>=4.15.0 || ^>=4.16.0 || ^>=4.17.0 || ^>=4.18.0 || ^>=4.19.0 || ^>=4.20.0
    • ghc ^>=7.10.3 || ^>=8.0.2 || ^>=8.2.2 || ^>=8.4.1 || ^>=8.6.1 || ^>=8.8.1 || ^>=8.10.1 || ^>=9.0.1 || ^>=9.2.1 || ^>=9.4.1 || ^>=9.6.1 || ^>=9.8.1 || ^>=9.10.1
    • semigroups ^>=0.20
    • Show all…
  • Dependents (0)

  • Package Flags

      noisy-deprecations
       (on by default)

      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.

NoRecursion plugin

A GHC plugin to remove support for recursion

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.

usage

Add no-recursion to your build dependencies.

Add -fplugin NoRecursion to your GHC options. This can be done per-module with

{-# OPTIONS_GHC -fplugin NoRecursion #-}

Now, any recursion in that module will result in a compilation failure.

NB: This won’t prevent you from using recursive functions imported from other modules, but inlined definitions from other modules will be checked.

allowing some recursion

NoRecursion supports two source annotations: "Recursion" and "NoRecursion".

You can re-enable recursion for individual top-level names like

recDef :: a -> b
recDef = myRecDef
{-# ANN recDef "Recursion" #-}

Or you can re-enable recursion for an entire module with

{-# ANN module "Recursion" #-}

And then you can re-disable recursion for individual names with

nonRecDef :: a -> a
nonRecDef = id
{-# ANN nonRecDef "NoRecursion" #-}

If both '"Recursion"' and "NoRecursion" annotations exist on the same name (or module), it’s treated as NoRecursion.

NB: If multiple names are mutually recursive, then they must all have recursion enabled to avoid being flagged by the plugin.

ANN has some caveats:

For more about how to use annotations, see the GHC User’s Guide.

licensing

This package is licensed under The GNU AGPL 3.0 or later. If you need a license for usage that isn’t covered under the AGPL, please contact Greg Pfeil.

When last checked, all transitive dependencies were licensed under The 3-Clause BSD License. However, you should review the license report for more details.

comparisons

Other projects similar to this one, and how they differ.

WartRemover

WartRemover is a Scala linting tool. A Recursion wart was added in 2017, and I’ve been meaning to write this plugin ever since. It only took seven years to find a few hours to make it happen …