Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/nofib/real/infer/StateX.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


module StateX (StateX, returnSX, eachSX, thenSX, toSX, putSX, getSX, useSX) where

data  StateX s a      =   MkSX (s -> a)
rep (MkSX f)          =   f
returnSX returnX x    =   MkSX (\s -> returnX (x, s))
eachSX eachX xSX f    =   MkSX (\s -> rep xSX s `eachX` (\(x,s') -> (f x, s')))
thenSX thenX xSX kSX  =   MkSX (\s -> rep xSX s `thenX` (\(x,s') -> rep (kSX x) s'))
toSX eachX xX         =   MkSX (\s -> xX `eachX` (\x -> (x,s)))
putSX returnX s'      =   MkSX (\s -> returnX ((), s'))
getSX returnX         =   MkSX (\s -> returnX (s,s))
useSX eachX s xSX     =   rep xSX s `eachX` (\(x,s') -> x)

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].