main = do print "Hello World !"
ghc test.hs
./test
ghci
:l test.hs
test
Pour quitter le ghci c'est :q
module LIb (somefunc) where
somefunc :: IO()
somefunc = putStrLn "SomeFunc"
module Main where
import Lib
main :: IO()
main = someFunc
Bool
Char
Integer
Int
Float
Double
kilo :: Int
kilo = 1000
mega :: Int
mega = kilo ^ (2::Int) //will be an int, numeric operation typically consume and produce values of the same type
intList :: [Int]
intList = [1, 2, 3]
At least two values joined, no maximum
intCharDoubleTriple :: (Int, Char, Double)
intCharDoubleTriple :: (1, 'a', 2)
module Darts (score) where
score :: Float -> Float -> Int
score x y
| distance > 10 = 0
| distance > 5 = 1
| distance > 1 = 5
| otherwise = 10
where distance = sqrt(x^2 + y^2)