Changeset 180
- Timestamp:
- Jan 24, 2008, 12:52:28 PM (18 years ago)
- Author:
- neil.c.c.brown
- Message:
-
Fixed the indentation of the code that was trailing off the right-hand edge of the screen
- File:
-
- 1 edited
- docs/trunk/hacking-guide/tock-intro.tex (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
docs/trunk/hacking-guide/tock-intro.tex
r179 r180 106 106 107 107 \begin{lstlisting} 108 doProcess :: A.Process -> PassM A.Process 109 doProcess (A.Assign m vs@(_:_:_) (A.ExpressionList _ es)) 110 = do ts <- mapM typeOfVariable vs 111 specs <- sequence [makeNonceVariable "assign_temp" m t A.VariableName A.Original | t <- ts] 112 let temps = [A.Variable m n | A.Specification _ n _ <- specs] 113 let first = [A.Assign m [v] (A.ExpressionList m [e]) | (v, e) <- zip temps es] 114 let second = [A.Assign m [v] (A.ExpressionList m [A.ExprVariable m v']) | (v, v') <- zip vs temps] 115 return $ A.Seq m $ foldl (\s spec -> A.Spec m spec s) (A.Several m (map (A.OnlyP m) (first ++ second))) specs 116 doProcess p = doGeneric p 108 doProcess :: A.Process -> PassM A.Process 109 doProcess (A.Assign m vs@(_:_:_) (A.ExpressionList _ es)) 110 = do ts <- mapM typeOfVariable vs 111 specs <- sequence 112 [makeNonceVariable "assign_temp" m t A.VariableName A.Original | t <- ts] 113 let temps = [A.Variable m n | A.Specification _ n _ <- specs] 114 let first = [A.Assign m [v] (A.ExpressionList m [e]) | (v, e) <- zip temps es] 115 let second = [A.Assign m [v] (A.ExpressionList m [A.ExprVariable m v']) 116 | (v, v') <- zip vs temps] 117 return $ A.Seq m $ foldl (\s spec -> A.Spec m spec s) 118 (A.Several m (map (A.OnlyP m) (first ++ second))) specs 119 doProcess p = doGeneric p 117 120 \end{lstlisting} 118 121 … … 155 158 156 159 \begin{lstlisting} 157 makeNonceVariable :: CSM m => String -> Meta -> A.Type -> A.NameType -> A.AbbrevMode -> m A.Specification 160 makeNonceVariable :: CSM m => String -> Meta -> A.Type -> 161 A.NameType -> A.AbbrevMode -> m A.Specification 158 162 \end{lstlisting} 159 163 … … 190 194 Note that you there is nor really an opposite of the return function (something of type \lstinline|m a -> a|). 191 195 Values can never really be `freed' from the monad; everything around them just gets lifted inside. 196 (追記) (追記ここまで) 197 (追記) %TODO explain what the code actually does, too! (追記ここまで) 192 198 193 199 \subsection{The PassM monad} … … 216 222 -> CompState -- ^ The state to use to run the pass. 217 223 -> IO (CompState, Either ErrorReport b) -- ^ The resultant state, and either an error or the successful outcome of the pass. 218 runPass actualPass startState = (liftM (\(x,y) -> (y,x))) (runStateT (runErrorT actualPass) startState) 224 runPass actualPass startState = (liftM (\(x,y) -> (y,x))) 225 (runStateT (runErrorT actualPass) startState) 219 226 \end{lstlisting} 220 227
Note:
See TracChangeset
for help on using the changeset viewer.