Commit 7a2e933b authored by Ryan Scott's avatar Ryan Scott

Use Data.Functor.Const to implement Data.Data internals

Summary:
`Data.Data` uses an internal datatype `CONST`, which can be replaced
completely by `Const` from `Data.Functor.Const`.

Reviewers: austin, bgamari, hvr

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2396
parent bd510644
......@@ -114,6 +114,7 @@ module Data.Data (
------------------------------------------------------------------------------
import Data.Functor.Const
import Data.Either
import Data.Eq
import Data.Maybe
......@@ -323,12 +324,12 @@ class Typeable a => Data a where
-- | A generic query with a left-associative binary operator
gmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r
gmapQl o r f = unCONST . gfoldl k z
gmapQl o r f = getConst . gfoldl k z
where
k :: Data d => CONST r (d->b) -> d -> CONST r b
k c x = CONST $ (unCONST c) `o` f x
z :: g -> CONST r g
z _ = CONST r
k :: Data d => Const r (d->b) -> d -> Const r b
k c x = Const $ (getConst c) `o` f x
z :: g -> Const r g
z _ = Const r
-- | A generic query with a right-associative binary operator
gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r
......@@ -424,10 +425,6 @@ was transformed successfully.
)
-- | The constant type constructor needed for the definition of gmapQl
newtype CONST c a = CONST { unCONST :: c }
-- | Type constructor for adding counters to queries
data Qi q a = Qi Int (Maybe q)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment