-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
executable file
·37 lines (33 loc) · 1018 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Main (main) where
import Data.Maybe (fromMaybe)
import System.Console.GetOpt (ArgDescr(..), ArgOrder(..), OptDescr(..), getOpt)
import System.Environment (getArgs)
import Text.Read (readMaybe)
import Interp (Conf(name), initial)
import Dibujos.Ejemplo (ejemploConf)
import Dibujos.Feo (feoConf)
import Dibujos.GrillaNumerada (grillaConf)
import Dibujos.Escher (escherConf)
-- Lista de configuraciones de los dibujos
configs :: [Conf]
configs = [ejemploConf, feoConf, grillaConf, escherConf]
-- Dibuja el dibujo n
initial' :: [Conf] -> String -> IO ()
initial' [] n = do
putStrLn $ "No hay un dibujo llamado " ++ n
initial' (c : cs) "--lista" =
do
putStrLn "Dibujos disponibles: "
mapM_ (\c -> putStrLn $ " " ++ name c) configs
putStrLn "Seleccione el dibujo a imprimir"
n <- getLine
initial' configs n
initial' (c : cs) n =
if n == name c then
initial c 400
else
initial' cs n
main :: IO ()
main = do
args <- getArgs
initial' configs $ head args