no-recursion: A GHC plugin to remove support for recursion

[ agpl, library, recursion ] [ Propose Tags ]

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.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
noisy-deprecations

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.

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.2.0
Dependencies base (>=4.8.2 && <4.9 || >=4.9.1 && <4.10 || >=4.10.1 && <4.11 || >=4.11.0 && <4.12 || >=4.12.0 && <4.13 || >=4.13.0 && <4.14 || >=4.14.0 && <4.15 || >=4.15.0 && <4.16 || >=4.16.0 && <4.17 || >=4.17.0 && <4.18 || >=4.18.0 && <4.19 || >=4.19.0 && <4.20), ghc (>=7.10.3 && <7.11 || >=8.0.2 && <8.1 || >=8.2.2 && <8.3 || >=8.4.1 && <8.5 || >=8.6.1 && <8.7 || >=8.8.1 && <8.9 || >=8.10.1 && <8.11 || >=9.0.1 && <9.1 || >=9.2.1 && <9.3 || >=9.4.1 && <9.5 || >=9.6.1 && <9.7 || >=9.8.1 && <9.9), semigroups (>=0.20 && <0.21) [details]
License AGPL-3.0-or-later
Copyright 2024 Greg Pfeil
Author Greg Pfeil <greg@technomadic.org>
Maintainer Greg Pfeil <greg@technomadic.org>
Category Recursion
Home page https://github.com/sellout/no-recursion#readme
Bug tracker https://github.com/sellout/no-recursion/issues
Source repo head: git clone https://github.com/sellout/no-recursion
Uploaded by sellout at 2024-04-16T07:19:00Z
Distributions
Downloads 93 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for no-recursion-0.1.1.0

[back to package description]

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.

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 …