I'm having a problem with an application I'm working on where sClose in Network.Socket blocks inside the call to close. Unfortunately I'm using Unix domain sockets which don't support any of the timeout socket options, at least on OS X. Functions like timeout don't work since the FFI call is unsafe. Is there anything that can be done to timeout a call like this outside of killing the entire process?submitted by swift1337
[link] [4 comments]
I'm really new to haskell and I really don't understand IO. All I want to do is read in a number from the user and print out the successor of that number. Something like this:main = do putStrLn "What number do you want to find the sqrt of? : " name <- getLine print $ succ name
I've been reading and i've found one persons explanation:prompt :: (Read a) => String -> IO a prompt s = putStr s >> getLine >>= return . read triArea :: (Fractional a) => a -> a -> a triArea base height = (base * height) / 2 main :: IO () main = do base <- prompt "The base? " height <- prompt "The height? " let area = triArea base height putStrLn $ "The area of that triangle is " ++ show (area :: Float)
Which to be completely honest doesn't make any sense to me. I looked up >> and >>= on Hoogle, but I don't understand the content.
Thanks everyone, I got it to work!prompt x = do putStrLn x number <- getLine return number main = do number <- prompt " Please input a number: " print $ succ ( read number :: Int) submitted by yyttr3
[link] [18 comments]