adjust some of the names in GHC.HetMet.GArrow
authorAdam Megacz <megacz@cs.berkeley.edu>
Sat, 19 Mar 2011 19:47:25 +0000 (12:47 -0700)
committerAdam Megacz <megacz@cs.berkeley.edu>
Tue, 31 May 2011 21:59:08 +0000 (14:59 -0700)
GHC/HetMet/Arrow.hs
GHC/HetMet/GArrow.hs

index 39bd2fe..8352c78 100644 (file)
@@ -39,8 +39,8 @@ instance Arrow a => GArrowCopy a (,) where
 instance Arrow a => GArrowSwap a (,) where
   ga_swap      =  arr (\(x,y) -> (y,x))
 
-instance Arrow a => GArrowLiteral a (,) b where
-  ga_literal x = arr (\() -> x)
+instance Arrow a => GArrowConstant a (,) where
+  ga_constant x = arr (\() -> x)
 
 instance Arrow a => GArrowReify a (,) where
   ga_reify     =  arr
index e1ac446..9b15116 100644 (file)
@@ -15,13 +15,19 @@ module GHC.HetMet.GArrow (
   GArrowCopy(..),
   GArrowSwap(..),
   GArrowLoop(..),
+  GArrowConstant(..),
+  GArrowRun(..),
   GArrowReify(..),
-  GArrowReflect(..),
-  GArrowLiteral(..)
+  GArrowReflect(..)
 ) where
 import Control.Category
 
+------------------------------------------------------------------------
+-- The main GArrow class
+
 class Category g => GArrow g (**) | g -> (**) where
+--id           :: g x x
+--comp         :: g x y -> g y z -> g x z
   ga_first     :: g x y -> g (x ** z) (y ** z)
   ga_second    :: g x y -> g (z ** x) (z ** y)
   ga_cancell   :: g (()**x) x
@@ -31,29 +37,58 @@ class Category g => GArrow g (**) | g -> (**) where
   ga_assoc     :: g ((x**y)**z) (x**(y**z))
   ga_unassoc   :: g (x**(y**z)) ((x**y)**z)
 
-class GArrow g (**) => GArrowDrop g (**) where
-  ga_drop      :: g x ()
+
+------------------------------------------------------------------------
+-- The three context-manipulation classes
 
 class GArrow g (**) => GArrowCopy g (**) where
   ga_copy      :: g x (x**x)
 
+class GArrow g (**) => GArrowDrop g (**) where
+  ga_drop      :: g x ()
+
 class GArrow g (**) => GArrowSwap g (**) where
-  ga_swap          :: g (x**y) (y**x)
+  ga_swap      :: g (x**y) (y**x)
+
+ga_swap_second f =
+   ga_swap >>> ga_first f >>> ga_swap
+   -- implementation of ga_second for GArrowSwap
+   -- See also
+   -- http://haskell.org/haskellwiki/Class_system_extension_proposal
+   -- "Allowing superclass methods to be overridden in derived classes";
+   -- if we had this we could do a better job here
+
+
 
--- implementation of ga_second for GArrowSwap instances
-ga_swap_second f = ga_swap >>> ga_first f >>> ga_swap
+------------------------------------------------------------------------
+-- Loop
 
 class GArrow g (**) => GArrowLoop g (**) where
   ga_loop      :: g (x**z) (y**z) -> g x y
 
-class GArrow g (**) => GArrowLiteral g (**) a where
-  ga_literal   :: a -> g () a
 
--- not sure -- subject to change
+
+------------------------------------------------------------------------
+-- Constant and Run, which are dual to each other
+
+class GArrow g (**) => GArrowConstant g (**) where
+  ga_constant  :: a -> g () a
+
+-- the dual of GArrowConstant
+class GArrow g (**) => GArrowRun g (**) where
+  ga_run       :: g () a -> a
+
+
+
+------------------------------------------------------------------------
+-- Reify and Reflect, which are "curried" versions
+
+-- Not sure -- subject to change.  If you have this, you're basically
+-- a Control.Arrow; you can also define essentially all the other
+-- methods of GArrow, GArrowDrop, GArrowCopy, etc in terms of this.
 class GArrow g (**) => GArrowReify g (**) where
   ga_reify     :: (x -> y) -> g x y
 
 -- not sure -- subject to change
 class GArrow g (**) => GArrowReflect g (**) where
   ga_reflect   :: g x y -> (x -> y)
-