tite fractale

marche.hs

télécharger

type Altitude = Int

haut :: Altitude -> Altitude
haut a = a + 1

bas :: Altitude -> Altitude
bas a = a - 1

hautM :: Altitude -> AltitudeM
hautM a = a + 1

basM :: Altitude -> Altitude
basM a = a - 1

(-:) :: a -> (a -> b) -> b
x -: f = f x

data AltitudeM a = SousTerre | EnVol a
    deriving (Show)

EnVol :: a -> AltitudeM a

instance Monad AltitudeM where
    (Envol a) >>= f   = f a
    SousTerre >>= _   = SousTerre

    return            = EnVol

main :: IO ()
main = do
    putStrLn "0 -: haut -: bas -: haut"
    putStrLn (show (0 -: haut -: bas -: haut))
    putStrLn "0 -: haut -: bas -: bas -: haut"
    putStrLn (show (0 -: haut -: bas -: bas -: haut))
    input <- getLine
    if input == "exit" then
        putStrLn "Fini."
    else do
        putStrLn ("input = " ++ input)
        main









Page générée le 27/05/2021, 09h53'27" (page virtuelle).
historique global