------------------------------------------------------------------------------
+
+-- | Flexible type extension
+ext1 :: (Data a, Typeable1 t)
+ => c a
+ -> (forall a. Data a => c (t a))
+ -> c a
+ext1 def ext = maybe def id (cast0to1 ext)
+
+
-- | Type extension of transformations for unary type constructors
ext1T :: (Data d, Typeable1 t)
=> (forall d. Data d => d -> d)
toConstr, -- :: a -> Constr
fromConstr, -- :: Constr -> a
dataTypeOf, -- :: a -> DataType
- ext1, -- type extension for unary type constructors
- ext2 -- type extension for binary type constructors
+ cast0to1, -- mediate types and unary type constructors
+ cast0to2 -- mediate types and binary type constructors
),
-- * Constructor representations
------------------------------------------------------------------------------
--
--- Type extension for unary and binary type constructors
+-- Mediate types and type constructors
--
------------------------------------------------------------------------------
- -- | Type extension for unary type constructors
- ext1 :: Typeable1 t
- => c a
- -> (forall a. Data a => c (t a))
- -> c a
+ -- | Mediate types and unary type constructors
+ cast0to1 :: Typeable1 t
+ => (forall a. Data a => c (t a))
+ -> Maybe (c a)
+ cast0to1 _ = Nothing
- ext1 def ext = def
+ -- | Mediate types and binary type constructors
+ cast0to2 :: Typeable2 t
+ => (forall a b. (Data a, Data b) => c (t a b))
+ -> Maybe (c a)
+ cast0to2 _ = Nothing
- -- | Type extension for binary type constructors
- ext2 :: Typeable2 t
- => c a
- -> (forall a b. (Data a, Data b) => c (t a b)) -> c a
- ext2 def ext = def
-
------------------------------------------------------------------------------
--
1 -> []
2 -> undefined:undefined
dataTypeOf _ = listDataType
- ext1 def ext = maybe def id (cast1 ext)
-
+ cast0to1 = cast1
--
-- The gmaps are given as an illustration.
1 -> Nothing
2 -> Just undefined
dataTypeOf _ = maybeDataType
- ext1 def ext = maybe def id (cast1 ext)
+ cast0to1 = cast1
--
fromConstr c = case conIndex c of
1 -> (undefined,undefined)
dataTypeOf _ = productDataType
- ext2 def ext = maybe def id (cast2 ext)
+ cast0to2 = cast2
--
1 -> Left undefined
2 -> Right undefined
dataTypeOf _ = eitherDataType
- ext2 def ext = maybe def id (cast2 ext)
+ cast0to2 = cast2
{-
toConstr _ = FunConstr
fromConstr _ = undefined
dataTypeOf _ = FunType
- ext2 def ext = maybe def id (cast2 ext)
+ cast0to2 = cast2