• Keine Ergebnisse gefunden

Functions Operating on the IO Monad

N/A
N/A
Protected

Academic year: 2021

Aktie "Functions Operating on the IO Monad"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Functions Operating on the IO Monad

putChar :: Char -> IO () getChar :: IO Char (>>) :: IO a -> IO b -> IO b return :: a -> IO a

b IO2

IO1 IO2 b

a

IO1 >> =

(>>=) :: IO a -> (a -> IO b) -> IO b

a

IO1

b IO2

a

a

IO1

b IO2

a

>>= =

getChar >> return () reads a character and ignores it

getChar >>= putChar reads a character and prints it on the screen

27

(2)

do-Notation

gets :: Int -> IO String gets n = if n <= 0

then return []

else getChar >>= \x ->

gets (n-1) >>= \xs ->

return (x:xs) p >>= \x ->

q >>= \y ->

r

can be written as

do x <- p y <- q r

gets :: Int -> IO String

gets n = if n <= 0 then return []

else do x <- getChar

xs <- gets (n-1) return (x:xs)

28

Referenzen

ÄHNLICHE DOKUMENTE

Originally introduced for dynamical systems without inputs, the concept of Lyapunov functions [11] was extended to control Lyapunov functions (CLFs) by Artstein [2] and Sontag [18]

Perracchione Lectures on radial basis functions In practice, using different colours plot the Halton points for different values of M and N.. Again, by using the

Comprehension syntax provides a rather poor variety of syntactical forms, but in the early stages of query translation this is more of a virtue than a shortcoming. Monad

these models of computation capture the ‘true’ concepts of algorithmic

To build a Micnet networ k, the netutil program will require you to provide the names of the computers that will be in the network, a description or how the computers are to

If you have purchased all three Systems, (XENlX Operating System, Developmem System aDd Text Processina System) you can use the XENIX In.stallatioft Guitk

We note that methods which are taylored for vector problems can also be applied to matrix problems if one regards each matrix as a vector where the elements of the vector are

This manual contains introductory and operational information for the DN3xx family of DOMAIN® nodes and associated peripherals. This guide is intended for those