News aggregator

How to work around blocking in an unsafe FFI call?

Haskell on Reddit - Tue, 01/21/2014 - 5:09pm

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]
Categories: Incoming News

Associated patterns

haskell-cafe - Tue, 01/21/2014 - 12:31pm
Dear haskell-cafe, I've read in Reddit that pattern synonyms have been merged in GHC HEAD [ http://www.reddit.com/r/haskell/comments/1vpaey/pattern_synonyms_merged_into_ghchead/ ]. I would like to know whether associated patterns, that is, patterns which come under the umbrella of a type class, have also been implemented. I think that associated patterns would fill the gap in difference of features between type classes and common data types. For plain data types, you can declare both functions and patterns (either via constructors or now via pattern synonyms). However, you can only declare functions (either term-level or type-level) in type classes. This means that the pattern match mechanism, very useful to get clear code, is not useful if you want to use type classes. Alejandro. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Haskell IO, how to read numbers?

Haskell on Reddit - Tue, 01/21/2014 - 6:54am

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.

EDIT::

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]
Categories: Incoming News

ghc-mod list: cannot satisfy -package cairo

haskell-cafe - Tue, 01/21/2014 - 5:44am
I'm receiving an error from ghc-mod in my cabal sandbox: %./.cabal-sandbox/bin/ghc-mod list Dummy:0:0:Error:<command line>: cannot satisfy -package cairo (use -v for more information) The obvious potential problem is that cairo isn't installed. However, %cabal repl Preprocessing executable 'Notation' for Notation-0.1.0.0... GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help ... Prelude Main> import Graphics.Rendering.Cairo Prelude Graphics.Rendering.Cairo Main> My cabal file includes: build-depends: base >=4.6 && <4.7, mtl >=2.1 && <2.2, containers >=0.4 && <0.5, cairo >= 0.12 && <= 0.13 I'm on OSX 10.9.1. I had to point cairo to gcc-4.9 instead of clang to make it compile. Where else can I look for the problem?
Categories: Offsite Discussion

MissingH fails to compile

haskell-cafe - Tue, 01/21/2014 - 3:54am
Dear Haskell developers, I am trying to build a current version of git-annex, and stumble over a compilation failure of one of its dependencies, MissingH. I am using GHC 7.4.2 and Cabal 1.18.0.2, both bootstrapped on RHEL 5.x/6.x using a helper makefile [1] that has worked fine so far. The command to install git-annex is cabal install git-annex-5.20140108 --flags=-assistant --flags=-dbus --flags=-webapp --flags=-webdav --flags=-xmpp The build log for MissingH-1.2.0.2 is attached. I would be glad for any pointers on how to resolve this issue. Thanks, Peter [1] http://git.colberg.org/packages/plain/packages.mk Building MissingH-1.2.0.2... Preprocessing library MissingH-1.2.0.2... [ 1 of 47] Compiling System.Console.GetOpt.Utils ( src/System/Console/GetOpt/Utils.hs, dist/build/System/Console/GetOpt/Utils.o ) [ 2 of 47] Compiling System.Debian ( src/System/Debian.hs, dist/build/System/Debian.o ) src/System/Debian.hs:31:1: Warning: Module `System.Cmd' is deprecated: Use "System.Proc
Categories: Offsite Discussion

k0ral/hbro · GitHub

del.icio.us/haskell - Mon, 01/20/2014 - 7:47pm
Categories: Offsite Blogs

k0ral/hbro · GitHub

del.icio.us/haskell - Mon, 01/20/2014 - 7:47pm
Categories: Offsite Blogs

yihuang/hosts-server · GitHub

del.icio.us/haskell - Mon, 01/20/2014 - 7:31pm
Categories: Offsite Blogs

yihuang/hosts-server · GitHub

del.icio.us/haskell - Mon, 01/20/2014 - 7:31pm
Categories: Offsite Blogs