Tabbas! Ga yadda hakan zai iya zama:
Ya zama ruwan dare gama gari ga masu haษaka Haskell su gamu da saฦon kuskure mai ban takaici: **โmodule 'Main' ba za a iya samu a gida ba".** Wannan batu na iya fitowa a yanayi daban-daban, amma sau da yawa yana nuni da cewa mai daukar nauyin shirin Haskell yana kokawa wajen gano mashigar shirin. Za mu bincika yadda za a warware wannan batu, mu shiga cikin ษakunan karatu da ayyuka da abin ya shafa, da aiwatar da mataki-mataki ta hanyar aiwatar da lambar don gano tushen tushen da gyara da ake buฦata.
Magani ga "module main ba za a iya samu a gida"
Don warware wannan, yana da mahimmanci don tabbatar da cewa wurin shigarwa 'babban' ya wanzu kuma an yi la'akari da shi da kyau kuma an shigo dashi cikin lambar Haskell. A cikin Haskell, aikin 'babban' yana aiki ne a matsayin wurin shigar mai tarawa, don haka ba za a iya tafiyar da shirin ba tare da shi ba. Duk lokacin da muka gudanar da shirin Haskell, aikin 'babban' shine farkon aiwatarwa.
main :: IO () main = putStrLn "Hello, World!"
A cikin ainihin misali na sama, 'babban' aiki ne mai sauฦi ba tare da gardama ba wanda ke dawo da tasirin IO. Wannan tasirin IO, lokacin da aka kashe shi, yana haifar da aiki (a wannan yanayin, buga saฦo zuwa daidaitaccen fitarwa).
Haskell Library da Ayyuka
Yawancin ษakunan karatu da ayyuka suna taka muhimmiyar rawa a shirye-shiryen Haskell. Misali, ' Gabatarwa' daidaitaccen ษakin karatu ne da aka shigo da shi ta tsohuwa a cikin kowane shirin Haskell. 'Prelude' ya ฦunshi muhimman azuzuwan da misalai, iri, da ayyuka, kuma yana taimakawa tare da ayyuka na yau da kullun. Koyaya, yana da mahimmanci don tabbatar da cewa ma'anar da ke cikin lambar ku ba ta yi karo da waษanda ke cikin 'Prelude' ba.
import Prelude hiding (main)
Wannan lambar tana ษoye aikin 'babban' daga ษakin karatu na 'Prelude', yana hana duk wani rikici mai yuwuwa. Aikin ku da ake kira 'babban' ya kamata a gane yanzu da kyau a matsayin wurin shigarwa na shirin ku.
Bayanin mataki-mataki na Code
Babban manufarmu ita ce tabbatar da an gane 'babban' a matsayin wurin ฦaddamar da shirin. Mataki na farko shine kafa aikin 'babban' don cim ma wani aiki; sau da yawa yana mayar da tasirin IO.
babba :: IO ()
main = yi
putStrLn "Shigar da sunan ku:"
suna <- getLine putStrLn $ "Sannu," ++ suna [/code] A cikin misalin da ke sama, 'main' yana sa mai amfani ya shigar da sunansa. Sannan ta dawo da wannan shigarwar ta amfani da 'getLine' (wani muhimmin aiki a cikin shirye-shiryen Haskell masu mu'amala da shi), kuma yana maraba da mai amfani da sunan da aka shigar.
Kurakurai na gama gari da Gyara
Yayin rubuta shirin Haskell, mutum na iya fuskantar kurakurai na gama-gari masu alaฦa da โba za a iya samun babban mabuษin a cikin gida ba.โ Wadannan na iya tasowa daga rikice-rikicen suna, batutuwan gano wurin shiga, ko matsalolin shigo da kaya. Ta hanyar fahimtar yadda ake warware waษannan matsalolin gama-gari, za ku kasance da isassun kayan aiki don magance rikitattun shirye-shiryen Haskellโwani fasaha mai kima ga sabbin masu shirye-shirye da ฦwararrun masu shirye-shiryen Haskell.
Ta wannan jagorar, ya kamata ku sami cikakkiyar fahimta game da sarrafa saฦon kuskure "Ba za a iya samun babban abu a cikin gida ba" da mahimmancin aikin 'babban' a cikin shirye-shiryen Haskell. Fannin Haskell yana da fa'ida da sarkakiya, amma tare da madaidaicin tunani da fahimta, yana da matuฦar lada don bincika.