GitXplorerGitXplorer
m

hashtag-coerce

public
17 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
a3646f988a2794fbbf8e6d509ff3e0ffc51b5708

Init

mmpickering committed 7 years ago

README

The README file for this repository.

hashtag-coerce is a GHC source plugin which detects opportunities to use coerce.

At the moment it just detects one simple example, where we are mapping a newtype constructor over a list. Operationally, this will traverse the list and apply the newtype constructor at each position.

For example,

newtype Baz = Baz Int

qux :: [Int] -> [Baz]
qux = map Baz

will cause the plugin to warn that the map Foo can be replaced with coerce.

src/ModuleA.hs:6:7: warning:
    The usage of 'map' can be replaced with coerce.
  |
6 | qux = map Baz
  |       ^^^^^^^

The plugin can only be used with GHC 8.6.1 which is scheduled to be released at the end of June.

In order to run the plugin, add hashtag-coerce as a dependency and compile with -fplugin=HashtagCoerce.