diff options
| author | David Feuer <david.feuer@gmail.com> | 2017-04-02 16:20:20 -0400 |
|---|---|---|
| committer | David Feuer <David.Feuer@gmail.com> | 2017-04-02 16:20:22 -0400 |
| commit | bf5e0eab60a11d494671793740122e381a707c1a (patch) | |
| tree | 08c50b4294e3265d994a1452f829aca59e3dacd4 /compiler/prelude/PrelNames.hs | |
| parent | 911055689eca26c7c2713e251646fa35359acba3 (diff) | |
| download | haskell-bf5e0eab60a11d494671793740122e381a707c1a.tar.gz | |
Derive the definition of null
We can sometimes produce much better code by deriving the
definition of `null` rather than using the default. For example,
given
data SnocList a = Lin | Snoc (SnocList a) a
the default definition of `null` will walk the whole list, but of
course we can stop as soon as we see `Snoc`. Similarly, if a
constructor contains some other `Foldable` type, we want to use its
`null` rather than folding over the structure.
Partially fixes Trac #13280
Reviewers: austin, bgamari, RyanGlScott
Reviewed By: RyanGlScott
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3402
Diffstat (limited to 'compiler/prelude/PrelNames.hs')
| -rw-r--r-- | compiler/prelude/PrelNames.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/prelude/PrelNames.hs b/compiler/prelude/PrelNames.hs index 94c2d64f7f..1f9f8f33df 100644 --- a/compiler/prelude/PrelNames.hs +++ b/compiler/prelude/PrelNames.hs @@ -836,7 +836,8 @@ uIntHash_RDR = varQual_RDR gHC_GENERICS (fsLit "uInt#") uWordHash_RDR = varQual_RDR gHC_GENERICS (fsLit "uWord#") fmap_RDR, replace_RDR, pure_RDR, ap_RDR, liftA2_RDR, foldable_foldr_RDR, - foldMap_RDR, traverse_RDR, mempty_RDR, mappend_RDR :: RdrName + foldMap_RDR, null_RDR, all_RDR, traverse_RDR, mempty_RDR, + mappend_RDR :: RdrName fmap_RDR = varQual_RDR gHC_BASE (fsLit "fmap") replace_RDR = varQual_RDR gHC_BASE (fsLit "<$") pure_RDR = nameRdrName pureAName @@ -844,6 +845,8 @@ ap_RDR = nameRdrName apAName liftA2_RDR = varQual_RDR gHC_BASE (fsLit "liftA2") foldable_foldr_RDR = varQual_RDR dATA_FOLDABLE (fsLit "foldr") foldMap_RDR = varQual_RDR dATA_FOLDABLE (fsLit "foldMap") +null_RDR = varQual_RDR dATA_FOLDABLE (fsLit "null") +all_RDR = varQual_RDR dATA_FOLDABLE (fsLit "all") traverse_RDR = varQual_RDR dATA_TRAVERSABLE (fsLit "traverse") mempty_RDR = varQual_RDR gHC_BASE (fsLit "mempty") mappend_RDR = varQual_RDR gHC_BASE (fsLit "mappend") |
