git.iko.soy/distributed-process
on master help sign in
Clean up static
6e8a333Edsko de Vries
distributed-process/src/Control/Distributed/Process.hs+2−1
@@ -137,6 +137,7 @@ import Control.Distributed.Process.Serializable (SerializableDict)
137import Control.Distributed.Process.Internal.Closure.BuiltIn
137import Control.Distributed.Process.Internal.Closure.BuiltIn
138 ( sdictUnit
138 ( sdictUnit
139 , sdictSendPort
139 , sdictSendPort
140+ , sndStatic
140 , idCP
141 , idCP
141 , seqCP
142 , seqCP
142 , bindCP
143 , bindCP
@@ -147,7 +148,7 @@ import Control.Distributed.Process.Internal.Closure.BuiltIn
147 , cpSend
148 , cpSend
148 , cpNewChan
149 , cpNewChan
149 )
150 )
150−import Control.Distributed.Static (closureCompose, sndStatic, staticClosure)
151+import Control.Distributed.Static (closureCompose, staticClosure)
151
152
152{-
153{-
153import Control.Distributed.Process.Internal.Closure.CP
154import Control.Distributed.Process.Internal.Closure.CP
distributed-process/src/Control/Distributed/Process/Closure.hs+2−26
@@ -228,17 +228,6 @@ module Control.Distributed.Process.Closure
228 -- * Primitive operations on static values
228 -- * Primitive operations on static values
229 , staticApply
229 , staticApply
230 , staticDuplicate
230 , staticDuplicate
231− -- * Static values
232− , idStatic
233− , composeStatic
234− , constStatic
235− , flipStatic
236− , fstStatic
237− , sndStatic
238− , firstStatic
239− , secondStatic
240− , splitStatic
241− , unitStatic
242 -- * Combinators on static values
231 -- * Combinators on static values
243 , staticCompose
232 , staticCompose
244 -- * Serialization dictionaries (and their static versions)
233 -- * Serialization dictionaries (and their static versions)
@@ -272,21 +261,9 @@ import Control.Distributed.Static
272 ( -- Introducing static values
261 ( -- Introducing static values
273 staticApply
262 staticApply
274 , staticDuplicate
263 , staticDuplicate
275− -- Static values
276− , idStatic
277− , composeStatic
278− , constStatic
279− , flipStatic
280− , fstStatic
281− , sndStatic
282− , firstStatic
283− , secondStatic
284− , splitStatic
285− , unitStatic
286 -- Combinators on static values
264 -- Combinators on static values
287 , staticCompose
265 , staticCompose
288 , staticClosure
266 , staticClosure
289− , closureSplit
290 )
267 )
291
268
292
269
@@ -304,10 +281,9 @@ import Control.Distributed.Process.Internal.Closure.TH
304 , functionTDict
281 , functionTDict
305 )
282 )
306import Control.Distributed.Process.Internal.Closure.BuiltIn
283import Control.Distributed.Process.Internal.Closure.BuiltIn
307− ( -- Remote table
284+ (
308− remoteTable
309 -- Static dictionaries and associated operations
285 -- Static dictionaries and associated operations
310− , staticDecode
286+ staticDecode
311 , sdictUnit
287 , sdictUnit
312 , sdictProcessId
288 , sdictProcessId
313 , sdictSendPort
289 , sdictSendPort
distributed-process/src/Control/Distributed/Process/Internal/Closure/BuiltIn.hs+15
@@ -6,6 +6,8 @@ module Control.Distributed.Process.Internal.Closure.BuiltIn
6 , sdictUnit
6 , sdictUnit
7 , sdictProcessId
7 , sdictProcessId
8 , sdictSendPort
8 , sdictSendPort
9+ -- * Some static values
10+ , sndStatic
9 -- * The CP type and associated combinators
11 -- * The CP type and associated combinators
10 , CP
12 , CP
11 , idCP
13 , idCP
@@ -21,6 +23,8 @@ module Control.Distributed.Process.Internal.Closure.BuiltIn
21 , cpNewChan
23 , cpNewChan
22 ) where
24 ) where
23
25
26+import Prelude hiding (snd)
27+import qualified Prelude (snd)
24import Data.ByteString.Lazy (ByteString)
28import Data.ByteString.Lazy (ByteString)
25import Data.Binary (decode, encode)
29import Data.Binary (decode, encode)
26import Data.Rank1Typeable (Typeable, ANY, ANY1, ANY2, ANY3, ANY4)
30import Data.Rank1Typeable (Typeable, ANY, ANY1, ANY2, ANY3, ANY4)
@@ -75,6 +79,7 @@ remoteTable =
75 . registerStatic "$expectDict" (toDynamic expectDict)
79 . registerStatic "$expectDict" (toDynamic expectDict)
76 . registerStatic "$newChanDict" (toDynamic newChanDict)
80 . registerStatic "$newChanDict" (toDynamic newChanDict)
77 . registerStatic "$cpSplit" (toDynamic cpSplit)
81 . registerStatic "$cpSplit" (toDynamic cpSplit)
82+ . registerStatic "$snd" (toDynamic snd)
78 where
83 where
79 decodeDict :: SerializableDict ANY -> ByteString -> ANY
84 decodeDict :: SerializableDict ANY -> ByteString -> ANY
80 decodeDict SerializableDict = decode
85 decodeDict SerializableDict = decode
@@ -112,6 +117,9 @@ remoteTable =
112 cpSplit :: (ANY1 -> Process ANY3) -> (ANY2 -> Process ANY4) -> (ANY1, ANY2) -> Process (ANY3, ANY4)
117 cpSplit :: (ANY1 -> Process ANY3) -> (ANY2 -> Process ANY4) -> (ANY1, ANY2) -> Process (ANY3, ANY4)
113 cpSplit f g (a, b) = f a >>= \c -> g b >>= \d -> return (c, d)
118 cpSplit f g (a, b) = f a >>= \c -> g b >>= \d -> return (c, d)
114
119
120+ snd :: (ANY1, ANY2) -> ANY2
121+ snd = Prelude.snd
122+
115--------------------------------------------------------------------------------
123--------------------------------------------------------------------------------
116-- Static dictionaries and associated operations --
124-- Static dictionaries and associated operations --
117--------------------------------------------------------------------------------
125--------------------------------------------------------------------------------
@@ -139,6 +147,13 @@ sdictSendPort :: Typeable a
139 => Static (SerializableDict a) -> Static (SerializableDict (SendPort a))
147 => Static (SerializableDict a) -> Static (SerializableDict (SendPort a))
140sdictSendPort = staticApply (staticLabel "$sdictSendPort_")
148sdictSendPort = staticApply (staticLabel "$sdictSendPort_")
141
149
150+--------------------------------------------------------------------------------
151+-- Static values --
152+--------------------------------------------------------------------------------
153+
154+sndStatic :: Static ((a, b) -> b)
155+sndStatic = staticLabel "$snd"
156+
142--------------------------------------------------------------------------------
157--------------------------------------------------------------------------------
143-- The CP type and associated combinators --
158-- The CP type and associated combinators --
144--------------------------------------------------------------------------------
159--------------------------------------------------------------------------------
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+4−5
@@ -66,14 +66,13 @@ import Prelude hiding (catch)
66#endif
66#endif
67
67
68import Data.Binary (decode)
68import Data.Binary (decode)
69−import Data.Typeable (Typeable, typeOf)
70import Data.Time.Clock (getCurrentTime)
69import Data.Time.Clock (getCurrentTime)
71import Data.Time.Format (formatTime)
70import Data.Time.Format (formatTime)
72import System.Locale (defaultTimeLocale)
71import System.Locale (defaultTimeLocale)
73import Control.Monad.Reader (ask)
72import Control.Monad.Reader (ask)
74import Control.Monad.IO.Class (MonadIO, liftIO)
73import Control.Monad.IO.Class (MonadIO, liftIO)
75import Control.Applicative ((<$>))
74import Control.Applicative ((<$>))
76−import Control.Exception (Exception, throw, throwIO, SomeException)
75+import Control.Exception (Exception, throwIO, SomeException)
77import qualified Control.Exception as Ex (catch, mask)
76import qualified Control.Exception as Ex (catch, mask)
78import Control.Concurrent.MVar (modifyMVar)
77import Control.Concurrent.MVar (modifyMVar)
79import Control.Concurrent.Chan (writeChan)
78import Control.Concurrent.Chan (writeChan)
@@ -90,7 +89,7 @@ import Control.Concurrent.STM
90import Control.Distributed.Process.Internal.CQueue (dequeue, BlockSpec(..))
89import Control.Distributed.Process.Internal.CQueue (dequeue, BlockSpec(..))
91import Control.Distributed.Process.Serializable (Serializable, fingerprint)
90import Control.Distributed.Process.Serializable (Serializable, fingerprint)
92import Data.Accessor ((^.), (^:), (^=))
91import Data.Accessor ((^.), (^:), (^=))
93−import Control.Distributed.Static (Closure(Closure), fromDynamic, dynTypeRep)
92+import Control.Distributed.Static (Typeable, Closure)
94import qualified Control.Distributed.Static as Static (unclosure)
93import qualified Control.Distributed.Static as Static (unclosure)
95import Control.Distributed.Process.Internal.Types
94import Control.Distributed.Process.Internal.Types
96 ( NodeId(..)
95 ( NodeId(..)
@@ -506,8 +505,8 @@ unClosure :: forall a. Typeable a => Closure a -> Process a
506unClosure closure = do
505unClosure closure = do
507 rtable <- remoteTable . processNode <$> ask
506 rtable <- remoteTable . processNode <$> ask
508 case Static.unclosure rtable closure of
507 case Static.unclosure rtable closure of
509− Nothing -> fail $ "Could not resolve closure " ++ show closure
508+ Left err -> fail $ "Could not resolve closure: " ++ err
510− Just x -> return x
509+ Right x -> return x
511
510
512--------------------------------------------------------------------------------
511--------------------------------------------------------------------------------
513-- Auxiliary functions --
512-- Auxiliary functions --
distributed-process/src/Control/Distributed/Process/Node.hs+6−9
@@ -31,7 +31,7 @@ import qualified Data.List as List (delete, (\\))
31import Data.Set (Set)
31import Data.Set (Set)
32import qualified Data.Set as Set (empty, insert, delete, member, (\\), fromList)
32import qualified Data.Set as Set (empty, insert, delete, member, (\\), fromList)
33import Data.Foldable (forM_)
33import Data.Foldable (forM_)
34−import Data.Maybe (isJust, fromMaybe)
34+import Data.Maybe (isJust)
35import Data.Typeable (Typeable)
35import Data.Typeable (Typeable)
36import Control.Category ((>>>))
36import Control.Category ((>>>))
37import Control.Applicative ((<$>))
37import Control.Applicative ((<$>))
@@ -69,7 +69,7 @@ import qualified Network.Transport as NT
69import Data.Accessor (Accessor, accessor, (^.), (^=), (^:))
69import Data.Accessor (Accessor, accessor, (^.), (^=), (^:))
70import qualified Data.Accessor.Container as DAC (mapDefault, mapMaybe)
70import qualified Data.Accessor.Container as DAC (mapDefault, mapMaybe)
71import System.Random (randomIO)
71import System.Random (randomIO)
72−import Control.Distributed.Static (RemoteTable, Closure(Closure), fromDynamic)
72+import Control.Distributed.Static (RemoteTable, Closure)
73import qualified Control.Distributed.Static as Static (unclosure)
73import qualified Control.Distributed.Static as Static (unclosure)
74import Control.Distributed.Process.Internal.Types
74import Control.Distributed.Process.Internal.Types
75 ( NodeId(..)
75 ( NodeId(..)
@@ -121,11 +121,6 @@ import Control.Distributed.Process.Internal.Primitives (expect, register, finall
121import qualified Control.Distributed.Process.Internal.Closure.BuiltIn as BuiltIn (remoteTable)
121import qualified Control.Distributed.Process.Internal.Closure.BuiltIn as BuiltIn (remoteTable)
122import qualified Control.Distributed.Static as Static (initRemoteTable)
122import qualified Control.Distributed.Static as Static (initRemoteTable)
123
123
124−-- import Control.Distributed.Process.Internal.Dynamic (fromDynamic)
125−-- import Control.Distributed.Process.Internal.Closure.Resolution (resolveClosure)
126−-- import qualified Control.Distributed.Process.Internal.Closure.Static as Static (__remoteTable)
127−-- import qualified Control.Distributed.Process.Internal.Closure.CP as CP (__remoteTable)
128−
129--------------------------------------------------------------------------------
124--------------------------------------------------------------------------------
130-- Initialization --
125-- Initialization --
131--------------------------------------------------------------------------------
126--------------------------------------------------------------------------------
@@ -509,7 +504,9 @@ ncEffectSpawn pid cProc ref = do
509 mProc <- unClosure cProc
504 mProc <- unClosure cProc
510 -- If the closure does not exist, we spawn a process that throws an exception
505 -- If the closure does not exist, we spawn a process that throws an exception
511 -- This allows the remote node to find out what's happening
506 -- This allows the remote node to find out what's happening
512− let proc = fromMaybe (fail $ "Error: unknown closure " ++ show cProc) mProc
507+ let proc = case mProc of
508+ Left err -> fail $ "Error: Could not resolve closure: " ++ err
509+ Right p -> p
513 node <- ask
510 node <- ask
514 pid' <- liftIO $ forkProcess node proc
511 pid' <- liftIO $ forkProcess node proc
515 liftIO $ sendMessage node
512 liftIO $ sendMessage node
@@ -603,7 +600,7 @@ isLocal :: LocalNode -> Identifier -> Bool
603isLocal nid ident = nodeOf ident == localNodeId nid
600isLocal nid ident = nodeOf ident == localNodeId nid
604
601
605-- | Lookup a local closure
602-- | Lookup a local closure
606−unClosure :: Typeable a => Closure a -> NC (Maybe a)
603+unClosure :: Typeable a => Closure a -> NC (Either String a)
607unClosure closure = do
604unClosure closure = do
608 rtable <- remoteTable <$> ask
605 rtable <- remoteTable <$> ask
609 return (Static.unclosure rtable closure)
606 return (Static.unclosure rtable closure)
distributed-static/src/Control/Distributed/Static.hs+20−117
@@ -17,7 +17,6 @@ module Control.Distributed.Static
17 , staticLabel
17 , staticLabel
18 , staticApply
18 , staticApply
19 , staticDuplicate
19 , staticDuplicate
20−-- , staticTypeOf
21 -- * Eliminating static values
20 -- * Eliminating static values
22 , RemoteTable
21 , RemoteTable
23 , initRemoteTable
22 , initRemoteTable
@@ -27,18 +26,6 @@ module Control.Distributed.Static
27 , Closure(Closure)
26 , Closure(Closure)
28 , unclosure
27 , unclosure
29 , staticClosure
28 , staticClosure
30− -- * Static values
31− , idStatic
32− , composeStatic
33− , constStatic
34− , flipStatic
35− , fstStatic
36− , sndStatic
37− , firstStatic
38− , secondStatic
39− , splitStatic
40− , unitStatic
41− , appStatic
42 -- * Combinators on static values
29 -- * Combinators on static values
43 , staticCompose
30 , staticCompose
44 , staticSplit
31 , staticSplit
@@ -49,14 +36,13 @@ module Control.Distributed.Static
49 , closureCompose
36 , closureCompose
50 , closureSplit
37 , closureSplit
51 -- * Re-exports
38 -- * Re-exports
39+ , Typeable
52 , Dynamic
40 , Dynamic
53 , toDynamic
41 , toDynamic
54− , fromDynamic
55− , dynTypeRep
56 ) where
42 ) where
57
43
58−import Prelude hiding (id, (.), const, flip, fst, snd)
44+import Prelude hiding (const, fst, snd)
59−import qualified Prelude (const, flip, fst, snd)
45+import qualified Prelude (const, fst, snd)
60import Data.Binary
46import Data.Binary
61 ( Binary(get, put)
47 ( Binary(get, put)
62 , Put
48 , Put
@@ -70,9 +56,8 @@ import Data.ByteString.Lazy (ByteString, empty)
70import Data.Map (Map)
56import Data.Map (Map)
71import qualified Data.Map as Map (lookup, empty, insert)
57import qualified Data.Map as Map (lookup, empty, insert)
72import Control.Applicative ((<$>), (<*>))
58import Control.Applicative ((<$>), (<*>))
73−import Control.Category (Category(id, (.)))
74−import qualified Control.Arrow as Arrow (first, second, (***), app)
59+import qualified Control.Arrow as Arrow ((***), app)
75−import Data.Rank1Dynamic (Dynamic, toDynamic, fromDynamic, dynApply, dynTypeRep)
60+import Data.Rank1Dynamic (Dynamic, toDynamic, fromDynamic, dynApply)
76import Data.Rank1Typeable
61import Data.Rank1Typeable
77 ( Typeable
62 ( Typeable
78 , typeOf
63 , typeOf
@@ -141,24 +126,6 @@ staticApply (Static f) (Static x) = Static (StaticApply f x)
141staticDuplicate :: forall a. Static a -> Static (Static a)
126staticDuplicate :: forall a. Static a -> Static (Static a)
142staticDuplicate (Static x) = Static (StaticDuplicate x)
127staticDuplicate (Static x) = Static (StaticDuplicate x)
143
128
144−{-
145−-- | @staticTypeOf (x :: a)@ mimicks @static (undefined :: a)@ -- even if
146−-- @x@ is not static, the type of @x@ always is.
147−staticTypeOf :: forall a. Typeable a => a -> Static a
148−staticTypeOf _ = Static (StaticLabel "$undefined" (typeOf (undefined :: a)))
149−
150−typeOfStaticLabel :: StaticLabel -> TypeRep
151−typeOfStaticLabel = undefined
152−{-
153−typeOfStaticLabel (StaticLabel _ typ)
154− = typ
155−typeOfStaticLabel (StaticApply f x)
156− = fromJust $ funResultTy (typeOfStaticLabel f) (typeOfStaticLabel x)
157−typeOfStaticLabel (StaticDuplicate _ typ)
158− = typ
159−-}
160−-}
161−
162--------------------------------------------------------------------------------
129--------------------------------------------------------------------------------
163-- Eliminating static values --
130-- Eliminating static values --
164--------------------------------------------------------------------------------
131--------------------------------------------------------------------------------
@@ -169,84 +136,54 @@ newtype RemoteTable = RemoteTable (Map String Dynamic)
169-- | Initial remote table
136-- | Initial remote table
170initRemoteTable :: RemoteTable
137initRemoteTable :: RemoteTable
171initRemoteTable =
138initRemoteTable =
172− registerStatic "$id" (toDynamic identity)
173− . registerStatic "$compose" (toDynamic compose)
139+ registerStatic "$compose" (toDynamic compose)
174 . registerStatic "$const" (toDynamic const)
140 . registerStatic "$const" (toDynamic const)
175− . registerStatic "$flip" (toDynamic flip)
176− . registerStatic "$fst" (toDynamic fst)
177− . registerStatic "$snd" (toDynamic snd)
178− . registerStatic "$first" (toDynamic first)
179− . registerStatic "$second" (toDynamic second)
180 . registerStatic "$split" (toDynamic split)
141 . registerStatic "$split" (toDynamic split)
181− . registerStatic "$unit" (toDynamic ())
182 . registerStatic "$app" (toDynamic app)
142 . registerStatic "$app" (toDynamic app)
183 . registerStatic "$decodeEnvPair" (toDynamic decodeEnvPair)
143 . registerStatic "$decodeEnvPair" (toDynamic decodeEnvPair)
184 $ RemoteTable Map.empty
144 $ RemoteTable Map.empty
185 where
145 where
186− identity :: ANY -> ANY
187− identity = id
188−
189 compose :: (ANY2 -> ANY3) -> (ANY1 -> ANY2) -> ANY1 -> ANY3
146 compose :: (ANY2 -> ANY3) -> (ANY1 -> ANY2) -> ANY1 -> ANY3
190 compose = (.)
147 compose = (.)
191
148
192 const :: ANY1 -> ANY2 -> ANY1
149 const :: ANY1 -> ANY2 -> ANY1
193 const = Prelude.const
150 const = Prelude.const
194
151
195− flip :: (ANY1 -> ANY2 -> ANY3) -> ANY2 -> ANY1 -> ANY3
196− flip = Prelude.flip
197−
198− fst :: (ANY1, ANY2) -> ANY1
199− fst = Prelude.fst
200−
201− snd :: (ANY1, ANY2) -> ANY2
202− snd = Prelude.snd
203−
204− first :: (ANY1 -> ANY2) -> (ANY1, ANY3) -> (ANY2, ANY3)
205− first = Arrow.first
206−
207− second :: (ANY1 -> ANY2) -> (ANY3, ANY1) -> (ANY3, ANY2)
208− second = Arrow.second
209−
210 split :: (ANY1 -> ANY3) -> (ANY2 -> ANY4) -> (ANY1, ANY2) -> (ANY3, ANY4)
152 split :: (ANY1 -> ANY3) -> (ANY2 -> ANY4) -> (ANY1, ANY2) -> (ANY3, ANY4)
211 split = (Arrow.***)
153 split = (Arrow.***)
212
154
213− decodeEnvPair :: ByteString -> (ByteString, ByteString)
214− decodeEnvPair = decode
215−
216 app :: (ANY1 -> ANY2, ANY1) -> ANY2
155 app :: (ANY1 -> ANY2, ANY1) -> ANY2
217 app = Arrow.app
156 app = Arrow.app
218
157
158+ decodeEnvPair :: ByteString -> (ByteString, ByteString)
159+ decodeEnvPair = decode
160+
219-- | Register a static label
161-- | Register a static label
220registerStatic :: String -> Dynamic -> RemoteTable -> RemoteTable
162registerStatic :: String -> Dynamic -> RemoteTable -> RemoteTable
221registerStatic label dyn (RemoteTable rtable)
163registerStatic label dyn (RemoteTable rtable)
222 = RemoteTable (Map.insert label dyn rtable)
164 = RemoteTable (Map.insert label dyn rtable)
223
165
224-- Pseudo-type: RemoteTable -> Static a -> a
166-- Pseudo-type: RemoteTable -> Static a -> a
225−resolveStaticLabel :: RemoteTable -> StaticLabel -> Maybe Dynamic
167+resolveStaticLabel :: RemoteTable -> StaticLabel -> Either String Dynamic
226resolveStaticLabel (RemoteTable rtable) (StaticLabel label) =
168resolveStaticLabel (RemoteTable rtable) (StaticLabel label) =
227− Map.lookup label rtable
169+ case Map.lookup label rtable of
170+ Nothing -> Left $ "Invalid static label '" ++ label ++ "'"
171+ Just d -> Right d
228resolveStaticLabel rtable (StaticApply label1 label2) = do
172resolveStaticLabel rtable (StaticApply label1 label2) = do
229 f <- resolveStaticLabel rtable label1
173 f <- resolveStaticLabel rtable label1
230 x <- resolveStaticLabel rtable label2
174 x <- resolveStaticLabel rtable label2
231− case f `dynApply` x of
175+ f `dynApply` x
232− Left _err -> Nothing
233− Right y -> Just y
234resolveStaticLabel rtable (StaticDuplicate label) = do
176resolveStaticLabel rtable (StaticDuplicate label) = do
235 x <- resolveStaticLabel rtable label -- Resolve only to get type info
177 x <- resolveStaticLabel rtable label -- Resolve only to get type info
236− case toDynamic mkStatic `dynApply` x of
178+ toDynamic mkStatic `dynApply` x
237− Left _err -> Nothing
238− Right y -> Just y
239 where
179 where
240 mkStatic :: ANY -> Static ANY
180 mkStatic :: ANY -> Static ANY
241 mkStatic _ = Static label
181 mkStatic _ = Static label
242
182
243−unstatic :: Typeable a => RemoteTable -> Static a -> Maybe a
183+unstatic :: Typeable a => RemoteTable -> Static a -> Either String a
244−unstatic rtable (Static static) =
184+unstatic rtable (Static static) = do
245− case resolveStaticLabel rtable static of
185+ dyn <- resolveStaticLabel rtable static
246− Nothing -> Nothing
247− Just dyn -> case fromDynamic dyn of
186+ fromDynamic dyn
248− Left _err -> Nothing
249− Right x -> Just x
250
187
251--------------------------------------------------------------------------------
188--------------------------------------------------------------------------------
252-- Closures --
189-- Closures --
@@ -261,7 +198,7 @@ instance Typeable a => Binary (Closure a) where
261 get = Closure <$> get <*> get
198 get = Closure <$> get <*> get
262
199
263-- | Resolve a closure
200-- | Resolve a closure
264−unclosure :: Typeable a => RemoteTable -> Closure a -> Maybe a
201+unclosure :: Typeable a => RemoteTable -> Closure a -> Either String a
265unclosure rtable (Closure static env) = do
202unclosure rtable (Closure static env) = do
266 f <- unstatic rtable static
203 f <- unstatic rtable static
267 return (f env)
204 return (f env)
@@ -274,11 +211,6 @@ staticClosure static = Closure (staticConst static) empty
274-- Predefined static values --
211-- Predefined static values --
275--------------------------------------------------------------------------------
212--------------------------------------------------------------------------------
276
213
277−-- | Static version of 'id'
278−idStatic :: (Typeable a)
279− => Static (a -> a)
280−idStatic = staticLabel "$id"
281−
282-- | Static version of ('Prelude..')
214-- | Static version of ('Prelude..')
283composeStatic :: (Typeable a, Typeable b, Typeable c)
215composeStatic :: (Typeable a, Typeable b, Typeable c)
284 => Static ((b -> c) -> (a -> b) -> a -> c)
216 => Static ((b -> c) -> (a -> b) -> a -> c)
@@ -289,40 +221,11 @@ constStatic :: (Typeable a, Typeable b)
289 => Static (a -> b -> a)
221 => Static (a -> b -> a)
290constStatic = staticLabel "$const"
222constStatic = staticLabel "$const"
291
223
292−-- | Static version of 'flip'
293−flipStatic :: (Typeable a, Typeable b, Typeable c)
294− => Static ((a -> b -> c) -> b -> a -> c)
295−flipStatic = staticLabel "$flip"
296−
297−-- | Static version of 'fst'
298−fstStatic :: (Typeable a, Typeable b)
299− => Static ((a, b) -> a)
300−fstStatic = staticLabel "$fst"
301−
302−-- | Static version of 'snd'
303−sndStatic :: (Typeable a, Typeable b)
304− => Static ((a, b) -> b)
305−sndStatic = staticLabel "$snd"
306−
307−-- | Static version of 'Arrow.first'
308−firstStatic :: (Typeable a, Typeable b, Typeable c)
309− => Static ((a -> b) -> (a, c) -> (b, c))
310−firstStatic = staticLabel "$first"
311−
312−-- | Static version of 'Arrow.second'
313−secondStatic :: (Typeable a, Typeable b, Typeable c)
314− => Static ((a -> b) -> (c, a) -> (c, b))
315−secondStatic = staticLabel "$second"
316−
317-- | Static version of ('Arrow.***')
224-- | Static version of ('Arrow.***')
318splitStatic :: (Typeable a, Typeable a', Typeable b, Typeable b')
225splitStatic :: (Typeable a, Typeable a', Typeable b, Typeable b')
319 => Static ((a -> b) -> (a' -> b') -> (a, a') -> (b, b'))
226 => Static ((a -> b) -> (a' -> b') -> (a, a') -> (b, b'))
320splitStatic = staticLabel "$split"
227splitStatic = staticLabel "$split"
321
228
322−-- | Static version of @()@
323−unitStatic :: Static ()
324−unitStatic = staticLabel "$unit"
325−
326-- | Static version of 'Arrow.app'
229-- | Static version of 'Arrow.app'
327appStatic :: (Typeable a, Typeable b)
230appStatic :: (Typeable a, Typeable b)
328 => Static ((a -> b, a) -> b)
231 => Static ((a -> b, a) -> b)