Permalink
Browse files

Do not use recursive modules

(The reason is the TH's stage restriction.)
  • Loading branch information...
1 parent 68469be commit 6e9578c355e9a16669d455979224a364253249c7 @feuerbach committed Mar 14, 2013
@@ -38,36 +38,19 @@ module Data.Generics.Traversable
)
where
-import GHC.Exts (Constraint)
import Control.Applicative
import Control.Monad
import Data.Monoid
import Data.Functor.Identity
import Data.Functor.Constant
-import {-# SOURCE #-} Data.Generics.Traversable.Instances
+import Data.Generics.Traversable.Core
+import Data.Generics.Traversable.Instances
-- for documentation only
import Data.Foldable
import Data.Traversable
-class GTraversable (c :: * -> Constraint) a where
- -- | Applicative traversal over (a subset of) immediate subterms. This is
- -- a generic version of 'traverse' from "Data.Traversable".
- --
- -- The supplied function is applied only to the «interesting» subterms.
- --
- -- Other subterms are lifted using 'pure', and the whole structure is
- -- folded back using '<*>'.
- --
- -- 'gtraverse' has a default implementation @const pure@, which works for
- -- types without interesting subterms (in particular, atomic types).
- gtraverse
- :: (Applicative f, ?c :: p c)
- => (forall d . (GTraversable c d, c d, ?c :: p c) => d -> f d)
- -> a -> f a
- gtraverse = const pure
-
-- | Generic map over the immediate subterms
gmap
:: (GTraversable c a, ?c :: p c)
@@ -0,0 +1,23 @@
+{-# LANGUAGE ConstraintKinds, KindSignatures, MultiParamTypeClasses, RankNTypes, UndecidableInstances, ImplicitParams #-}
+module Data.Generics.Traversable.Core where
+
+import GHC.Exts (Constraint)
+import Control.Applicative
+
+class GTraversable (c :: * -> Constraint) a where
+ -- | Applicative traversal over (a subset of) immediate subterms. This is
+ -- a generic version of 'traverse' from "Data.Traversable".
+ --
+ -- The supplied function is applied only to the «interesting» subterms.
+ --
+ -- Other subterms are lifted using 'pure', and the whole structure is
+ -- folded back using '<*>'.
+ --
+ -- 'gtraverse' has a default implementation @const pure@, which works for
+ -- types without interesting subterms (in particular, atomic types).
+ gtraverse
+ :: (Applicative f, ?c :: p c)
+ => (forall d . (GTraversable c d, c d, ?c :: p c) => d -> f d)
+ -> a -> f a
+ gtraverse = const pure
+
@@ -3,7 +3,7 @@
-- exported by "Prelude"
module Data.Generics.Traversable.Instances () where
-import Data.Generics.Traversable
+import Data.Generics.Traversable.Core
import Data.Generics.Traversable.TH
import Control.Applicative
@@ -1 +0,0 @@
-module Data.Generics.Traversable.Instances where
@@ -10,7 +10,7 @@ module Data.Generics.Traversable.TH
import Language.Haskell.TH
import Control.Monad
-import Data.Generics.Traversable
+import Data.Generics.Traversable.Core
import Control.Applicative
err s = error $ "Data.Generics.Traversable.TH: " ++ s
@@ -18,6 +18,7 @@ library
exposed-modules: Data.Generics.Traversable
Data.Generics.Traversable.TH
other-modules:
+ Data.Generics.Traversable.Core
Data.Generics.Traversable.Instances
build-depends: base ==4.6.*, transformers ==0.3.*, template-haskell
default-language: Haskell2010

0 comments on commit 6e9578c

Please sign in to comment.