From f827975d749073dbc8224fe74a3ee39393b26640 Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sat, 19 Mar 2011 12:47:25 -0700 Subject: [PATCH] adjust some of the names in GHC.HetMet.GArrow --- GHC/HetMet/Arrow.hs | 4 ++-- GHC/HetMet/GArrow.hs | 57 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/GHC/HetMet/Arrow.hs b/GHC/HetMet/Arrow.hs index 39bd2fe..8352c78 100644 --- a/GHC/HetMet/Arrow.hs +++ b/GHC/HetMet/Arrow.hs @@ -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 diff --git a/GHC/HetMet/GArrow.hs b/GHC/HetMet/GArrow.hs index e1ac446..9b15116 100644 --- a/GHC/HetMet/GArrow.hs +++ b/GHC/HetMet/GArrow.hs @@ -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) - -- 1.7.10.4