[project @ 2004-02-15 13:24:42 by ralf]
authorralf <unknown>
Sun, 15 Feb 2004 13:24:43 +0000 (13:24 +0000)
committerralf <unknown>
Sun, 15 Feb 2004 13:24:43 +0000 (13:24 +0000)
Another commit of boilerplate refactoring
related to twin traversal and type introspection.
Clean-up. After some reflection the list
processing module was not regarded suitable
for the library (see List.hs removed).

Data/Generics.hs
Data/Generics/List.hs [deleted file]
Data/Generics/Twins.hs

index 58c5698..0732434 100644 (file)
@@ -24,7 +24,6 @@ module Data.Generics (
   module Data.Generics.Text,   -- generic read and show
   module Data.Generics.Twins,  -- twin traversal, e.g., generic eq
   module Data.Generics.Reify,  -- experimental reification theme
-  module Data.Generics.List    -- mapping over polymorphic lists
 
 #ifndef __HADDOCK__
        ,
@@ -53,4 +52,3 @@ import Data.Generics.Schemes
 import Data.Generics.Text
 import Data.Generics.Twins
 import Data.Generics.Reify
-import Data.Generics.List
diff --git a/Data/Generics/List.hs b/Data/Generics/List.hs
deleted file mode 100644 (file)
index 278a76f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module      :  Data.Generics.List
--- Copyright   :  (c) The University of Glasgow, CWI 2001--2004
--- License     :  BSD-style (see the file libraries/base/LICENSE)
--- 
--- Maintainer  :  libraries@haskell.org
--- Stability   :  experimental
--- Portability :  non-portable
---
--- \"Scrap your boilerplate\" --- Generic programming in Haskell 
--- See <http://www.cs.vu.nl/boilerplate/>. The present module illustrates
--- one possible treatment of polymorphic datatypes for specialising
--- generic functions.
---
------------------------------------------------------------------------------
-
-module Data.Generics.List ( 
-
-       -- * Processing polymorphic lists
-       isList,
-       isNil,
-       isCons,
-       lgmapQ
-
-
- ) where
-
-
-------------------------------------------------------------------------------
-
-#ifdef __HADDOCK__
-import Prelude
-#endif
-import Data.Maybe
-import Data.Generics.Basics
-
--------------------------------------------------------------
---
---     Processing polymorphic lists
---
--------------------------------------------------------------
-
-
--- | Test for list datatype
-isList :: Data a => a -> Bool
-isList x = typerepTyCon (typeOf x) ==
-           typerepTyCon (typeOf (undefined::[()]))
-
-
--- | Test for nil
-isNil :: Data a => a -> Bool
-isNil x = toConstr x == toConstr ([]::[()])
-
-
--- | Test for cons
-isCons :: Data a => a -> Bool
-isCons x = toConstr x == toConstr (():[])
-
-
--- | gmapQ for polymorphic lists; Nothing for other than lists
-lgmapQ :: forall a q. Data a => (forall a. Data a => a -> q) -> a -> Maybe [q]
-lgmapQ f x =
-  if not $ isList x 
-   then Nothing
-   else Just ( if isNil x
-                 then []
-                 else if isCons x
-                   then ( gmapQi 0 f x : gmapQi 1 (fromJust . lgmapQ f) x )
-                   else error "lgmapQ"
-             )
index d432289..c12e8c9 100644 (file)
@@ -245,9 +245,8 @@ couples of immediate subterms from the two given input terms.)
 geq x y = geq' x y
   where
     geq' :: forall a b. (Data a, Data b) => a -> b -> Bool
-    geq' x y = and ( (toConstr x == toConstr y)
-                   : tmapQ geq' x y
-                   )
+    geq' x y =     (toConstr x == toConstr y)
+                && and (tmapQ geq' x y)
 
 
 -- | Generic zip controlled by a function with type-specific branches