Personal tools

Cum se numeste modulul principal al unei aplicatii ?

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m
Line 1: Line 1:
 
[[Category:Ro]]
 
[[Category:Ro]]
 
<center>
 
<center>
http://www.haskell.org/wikiupload/images/3/35/Banim7.gif
+
http://www.haskell.org/wikiupload/3/35/Banim7.gif
   
 
Haskell ruleaza si sub Linux si sub Win-dows !
 
Haskell ruleaza si sub Linux si sub Win-dows !
Line 31: Line 31:
   
 
ghc --make Main.hs
 
ghc --make Main.hs
  +
  +
Dars e poate rula foarte bine siu cu hugs, caz in acre va trebu sa porniti programul tastand '''main''''. Nu exista o comanda RUN ca in Basic.
  +
  +
<haskell>
  +
  +
|| || || || || || ||__ Hugs 98: Based on the Haskell 98 standard
  +
||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005
  +
||---|| ___|| World Wide Web: http://haskell.org/hugs
  +
|| || Bugs: http://hackage.haskell.org/trac/hugs
  +
|| || Version: September 2006 _________________________________________
  +
  +
Haskell 98 mode: Restart with command line option -98 to enable extensions
  +
  +
  +
Type :? for help
  +
Main>
  +
Main> main
  +
Please enter your name:
  +
Mihai
  +
Hello, Mihai, how are you?
  +
  +
Main> main
  +
Please enter your name:
  +
Dan
  +
Hello, Dan, how are you?
  +
  +
Main> [Leaving Hugs]
  +
dan@computer:~
  +
</haskell>
  +
  +
 
----
 
----
 
Pagina in dezvoltare...
 
Pagina in dezvoltare...

Revision as of 14:07, 10 February 2011

Banim7.gif

Haskell ruleaza si sub Linux si sub Win-dows ! Fiti mai destepti si luati un computer cu Sistem de operare Mandriva Linux ! (Aceasta este o parodie a bannerului unei campanii publicitare, in spiritul dreptului la replica si al libertatii opiniei.)


Modulul principal se numeste Main. Salvati modulul in fisierul Main.hs.

-- Un program Hello World interactiv
module Main
  where
 
import IO
main = do
          hSetBuffering stdin LineBuffering
          putStrLn "Scrie-mi numele tau "
          name <- getLin
          putStrLn ("Salut, " ++ name ++ ". Ce mai faci ?")

Exemple similare de programe de IO scrise in do-notatie gasiti in cartile de la Biblioteca. Un pachet consistent este in anexa cartii prof. Mihai Giontineac (cartea alba). Sunt realizate de studentii acestuia, si pot sa mai aiba unele greseli asa ca rulati-le cu grija.

Compilarea cu ghc a modulului Main duce automat la compilarea tuturor modulelor.

ghc --make Main.hs

Dars e poate rula foarte bine siu cu hugs, caz in acre va trebu sa porniti programul tastand main'. Nu exista o comanda RUN ca in Basic.

||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__||  __||     Copyright (c) 1994-2005
||---||         ___||           World Wide Web: http://haskell.org/hugs
||   ||                         Bugs: http://hackage.haskell.org/trac/hugs
||   || Version: September 2006 _________________________________________
 
Haskell 98 mode: Restart with command line option -98 to enable extensions
 
 
Type :? for help
Main> 
Main> main
Please enter your name: 
Mihai
Hello, Mihai, how are you?
 
Main> main
Please enter your name: 
Dan
Hello, Dan, how are you?
 
Main> [Leaving Hugs]
dan@computer:~



Pagina in dezvoltare...