projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9940194
)
[project @ 1998-03-20 09:42:30 by sof]
author
sof
<unknown>
Fri, 20 Mar 1998 09:42:34 +0000
(09:42 +0000)
committer
sof
<unknown>
Fri, 20 Mar 1998 09:42:34 +0000
(09:42 +0000)
Add Functor instances
ghc/lib/exts/LazyST.lhs
patch
|
blob
|
history
ghc/lib/std/PrelST.lhs
patch
|
blob
|
history
diff --git
a/ghc/lib/exts/LazyST.lhs
b/ghc/lib/exts/LazyST.lhs
index
1d9cf60
..
29c7814
100644
(file)
--- a/
ghc/lib/exts/LazyST.lhs
+++ b/
ghc/lib/exts/LazyST.lhs
@@
-39,6
+39,14
@@
import PrelGHC
newtype ST s a = ST (PrelST.State s -> (a,PrelST.State s))
newtype ST s a = ST (PrelST.State s -> (a,PrelST.State s))
+instance Functor (ST s) where
+ map f m = ST $ \ s ->
+ let
+ ST m_a = m
+ (r,new_s) = m_a s
+ in
+ (f r,new_s)
+
instance Monad (ST s) where
return a = ST $ \ s -> (a,s)
instance Monad (ST s) where
return a = ST $ \ s -> (a,s)
diff --git
a/ghc/lib/std/PrelST.lhs
b/ghc/lib/std/PrelST.lhs
index
b3b5411
..
8513a6a
100644
(file)
--- a/
ghc/lib/std/PrelST.lhs
+++ b/
ghc/lib/std/PrelST.lhs
@@
-27,6
+27,11
@@
newtype ST s a = ST (State# s -> STret s a)
data STret s a = STret (State# s) a
data STret s a = STret (State# s) a
+instance Functor (ST s) where
+ map f (ST m) = ST $ \ s ->
+ case (m s) of { STret new_s r ->
+ STret new_s (f r) }
+
instance Monad (ST s) where
{-# INLINE return #-}
{-# INLINE (>>) #-}
instance Monad (ST s) where
{-# INLINE return #-}
{-# INLINE (>>) #-}