Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/libraries/Cabal/tests/wash2hs/hs/WASHOut.hs

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


module WASHOut where

-- output monad

data Out a = Out a ShowS

instance Monad Out where
  return a = Out a id
  m >>= f  = case m of
	       Out x shw1 ->
		 case f x of
                   Out y shw2 ->
		     Out y (shw1 . shw2)

runOut :: Out a -> ShowS
runOut (Out a shw) = shw

wrapper = (Out () .)

outString :: String -> Out ()
outString = wrapper showString

outChar :: Char -> Out ()
outChar = wrapper showChar

outs :: Show a => a -> Out ()
outs = wrapper shows

outShowS :: ShowS -> Out ()
outShowS = Out ()

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.