--- | Test for type equivalence
-sameType :: (Typeable a, Typeable b) => TypeVal a -> TypeVal b -> Bool
-sameType tva tvb = typeOf (undefinedType tva) ==
- typeOf (undefinedType tvb)
+-- | A convenient variation for kind "* -> *"
+castss :: (Typeable a, Typeable b) => t a -> Maybe (t b)
+castss x = r
+ where
+ r = if typeOf (get x) == typeOf (get (fromJust r))
+ then Just $ unsafeCoerce x
+ else Nothing
+ get :: t c -> c
+ get = undefined
+
+
+-- | Another variation
+castarr :: (Typeable a, Typeable b, Typeable c, Typeable d)
+ => (a -> t b) -> Maybe (c -> t d)
+castarr x = r
+ where
+ r = if typeOf (get x) == typeOf (get (fromJust r))
+ then Just $ unsafeCoerce x
+ else Nothing
+ get :: (e -> t f) -> (e, f)
+ get = undefined
+
+{-
+
+The variations castss and castarr are arguably not really needed.
+Let's discuss castss in some detail. To get rid of castss, we can
+require "Typeable (t a)" and "Typeable (t b)" rather than just
+"Typeable a" and "Typeable b". In that case, the ordinary cast would
+work. Eventually, all kinds of library instances should become
+Typeable. (There is another potential use of variations as those given
+above. It allows quantification on type constructors.
+
+-}