diff options
author | Ian Lynagh <igloo@earth.li> | 2008-01-13 13:16:58 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2008-01-13 13:16:58 +0000 |
commit | 02259d94c7a451e1b04e3ef500c533532477c0ac (patch) | |
tree | 6fb93ca263a43dad30492265336e88eefe23c176 /compiler/utils/State.hs | |
parent | b25d67d4c0398dbceca0165c3b43df0625e1e06a (diff) | |
download | haskell-02259d94c7a451e1b04e3ef500c533532477c0ac.tar.gz |
Fix warnings in utils/State
Diffstat (limited to 'compiler/utils/State.hs')
-rw-r--r-- | compiler/utils/State.hs | 62 |
1 files changed, 25 insertions, 37 deletions
diff --git a/compiler/utils/State.hs b/compiler/utils/State.hs index 578a7b3665..bf5b3a0d5e 100644 --- a/compiler/utils/State.hs +++ b/compiler/utils/State.hs @@ -1,63 +1,51 @@ -{-# OPTIONS -w #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings --- for details module State where -newtype State s a - = State - { runState' :: s -> (# a, s #) } +newtype State s a = State { runState' :: s -> (# a, s #) } instance Monad (State s) where - return x = State $ \s -> (# x, s #) - m >>= n = State $ \s -> - case runState' m s of - (# r, s' #) -> runState' (n r) s' + return x = State $ \s -> (# x, s #) + m >>= n = State $ \s -> case runState' m s of + (# r, s' #) -> runState' (n r) s' -get :: State s s -get = State $ \s -> (# s, s #) +get :: State s s +get = State $ \s -> (# s, s #) gets :: (s -> a) -> State s a -gets f = State $ \s -> (# f s, s #) +gets f = State $ \s -> (# f s, s #) -put :: s -> State s () -put s' = State $ \s -> (# (), s' #) +put :: s -> State s () +put s' = State $ \_ -> (# (), s' #) modify :: (s -> s) -> State s () modify f = State $ \s -> (# (), f s #) evalState :: State s a -> s -> a -evalState s i - = case runState' s i of - (# a, s' #) -> a +evalState s i = case runState' s i of + (# a, _ #) -> a execState :: State s a -> s -> s -execState s i - = case runState' s i of - (# a, s' #) -> s' +execState s i = case runState' s i of + (# _, s' #) -> s' runState :: State s a -> s -> (a, s) -runState s i - = case runState' s i of - (# a, s' #) -> (a, s') +runState s i = case runState' s i of + (# a, s' #) -> (a, s') mapAccumLM - :: Monad m - => (acc -> x -> m (acc, y)) -- ^ combining funcction - -> acc -- ^ initial state - -> [x] -- ^ inputs - -> m (acc, [y]) -- ^ final state, outputs + :: Monad m + => (acc -> x -> m (acc, y)) -- ^ combining funcction + -> acc -- ^ initial state + -> [x] -- ^ inputs + -> m (acc, [y]) -- ^ final state, outputs -mapAccumLM _ s [] = return (s, []) +mapAccumLM _ s [] = return (s, []) mapAccumLM f s (x:xs) - = do - (s1, x') <- f s x - (s2, xs') <- mapAccumLM f s1 xs - return (s2, x' : xs') + = do (s1, x') <- f s x + (s2, xs') <- mapAccumLM f s1 xs + return (s2, x' : xs') + |