-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC5S1.idr
25 lines (23 loc) · 892 Bytes
/
C5S1.idr
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
module Main
-- Using do notation, write a printLonger program that reads two strings and then dis- plays the length of the longer string.
printLonger : IO ()
printLonger = do putStr "First string: "
s1 <- getLine
let len1 = length s1
putStr "Second string: "
s2 <- getLine
let len2 = length s2
case len1 > len2 of
True => putStrLn $ cast len1
False => putStrLn $ cast len2
printLongerBind : IO ()
printLongerBind = putStr "First string: " >>=
\_ => getLine >>=
\s1 => putStr "Second string: " >>=
\_ => getLine >>=
(\s2 => let len1 = length s1
len2 = length s2 in
case len1 > len2 of
True => putStrLn $ cast len1
False => putStrLn $ cast len2
)