Prueba

Páginas: 2 (300 palabras) Publicado: 13 de diciembre de 2011
Como combino IO?
(>>=)::IO a -> (a->IO b) -> IO b
(>>)::IO a-> IO b -> IO b
return :: a-> IO a
LECTURA
* getChar :: IO char
* getLine :: IO String
*readFile :: String -> IO String
ESCRITURA
* putStr :: String->IO()
* putStrLn :: String->IO()
* putChar :: Char -> IO()
* writeFile :: String->String->IO()
print ::Show a => a->IO()
*print = putStr.show
Ej tonteria = getLine >>= putStrLn

NOTACION Do
Ej copiarFichero :: IO ()
copiarFichero = do
putStrLn “dame nombre fichero”nombreFich <- getLine
texto <- readFile nombreFich
putStr texto

procesa :: Int ->IO()
procesa ancho = do
texto <- readFile “patata.txt”
wrideFile “patataJust.txt” (jstDr anchotexto)
insistir :: (String -> String) -> IO()
insistir :: f = do
|putStrLn “dame 1 linea”
|línea <- getLine
| if line == “ ” then return ()
Else do
|putStrLn (f línea)|insitir f

main :: IO()
menú :: IO ()
menú = do
|putStrLn “1 le dare la vuelta a la frase”
|putStrLn “2 contare el numero de letras de la frase”
|putStrLn “3 te insultare”
|putStrLn“dame 1 opcion”
opc <-getLine
EjecutarOpción

EjecutarOpcion :: String -> IO()
EjecutarOpcion opc = do
|case opcInt of
| 1-> insistir reverse
| 2->insistir ______
|3-> putStrLn “Mamon”

Where
opcInt = (read opc)::Int read :: ___ => String -> a

EjecutarOpcion :: Int -> IO()
EjecutarOpcion opc = do
|case opcInt of
| 1-> insistirreverse
| 2->insistir ______
| 3-> putStrLn “Mamon”

getInt :: IO -> Int
getInt = do
|strInt <- getLine
|let elInt = read strInt
|return elInt

Restricciones en eluso de la notacion do
* cada línea debe de contener 1 unica acción de E/S
* todas las líneas empiezan con el mismo sangrado
* la clausula where se puede utilizar, con las mismas...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Prueba
  • Prueba
  • Prueba
  • Prueba
  • Prueba
  • Pruebas
  • Pruebas
  • Prueba

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS