News aggregator

End of support for test-framework-smallcheck and test-framework-golden

haskell-cafe - Mon, 09/08/2014 - 10:59pm
I'm going to stop maintaining the test-framework-smallcheck and test-framework-golden packages. I recommend switching to tasty's tasty-smallcheck and tasty-golden, respectively. If you are interested in taking over these test-framework packages, let me know. Otherwise, I will continue supporting them for the next 3 months and abandon/deprecate them afterwards. Roman _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Yesod Web Framework: Misassigned credit for conduit

Planet Haskell - Mon, 09/08/2014 - 6:00pm

When I was at ICFP last week, it became clear that I had made a huge mistake in the past three years. A few of us were talking, including Erik de Castro Lopo, and when I mentioned that he was the original inspiration for creating the conduit package, everyone else was surprised. So firstly: Erik, I apologize for not making it clear that you initially kicked off development by finding some fun corner cases in enumerator that were difficult to debug.

So to rectify that, I think it's only fair that I write the following:

  • conduit is entirely Erik's fault.
  • If you love conduit, write Erik a thank you email.
  • More importantly, if you hate conduit, there's no need to complain to me anymore. Erik presumably will be quite happy to receive all such further communications.
  • In other words, it's not my company, I just work here.

Thanks Erik :)

UPDATE Please also read my follow-up blog post clarifying this one, just in case you're confused.

Categories: Offsite Blogs

[code-review] Compute the most depended on packages in Hackage.

Haskell on Reddit - Mon, 09/08/2014 - 5:44pm

If you're interested in helping someone become a better Haskell programmer, I would appreciate a code review along with feedback & criticism. Thanks in advance!

http://lpaste.net/110771

Compute the most depended on packages in Hackage by requesting a list of all packages along with their cabal files. For each cabal file, get a list of unique dependencies. Count these up to determine how many packages depend on a particular package. Sort.

Insecurity

I am comfortable with Haskell, and really enjoy it, but to be shamefully honest it took me 4 hours to do this. I think it is because I am not familiar with the libraries--I think a large portion of the time was spent reading documentation and library code & tests (to see how to use the library!). Any advice on how to be more efficient? Two things I have started doing are try to use command line hoogle and haskell-mode more often, and grow a "cheat sheet" which is just a super dense collection of functions and their types. I write this out by hand.

Another thing I am weary of is that Haskell is beautiful, but when I try to write something 'real' or 'productive' in it, I generally hack my way through it and end up with.. not so beautiful code. Advice on how to grow or build great Haskell code from the beginning?

Parallelization

I have the Control.Concurrent.Async code commented out because when I have ulimit -n set to high enough, I eventually hit this problem:

file descriptor 1024 out of range for select (0--1024). Recompile with -threaded to work around this.

But, when I compile with -threaded, the program quickly hits this notorious issue:

getAddrInfo: does not exist (Name or service not known)

Google and friends will tell you that you need 'withSocketsDo' on Windows. But I am on a Linux machine, and I cannot find how else to debug. I have seen this error for a bad / ill-formed URL, but I don't think that is the case here because serial map runs fine.

Streaming library?

Is there any advantage to using a streaming library (pipes or conduit) to construct this code?

As far as performance goes, it appears to be okay (besides the parallelism trouble described above):

time cabal run +RTS -s Preprocessing executable 'hackage-mining' for hackage-mining-0.1.0.0... [("base",6533),("bytestring",2249),("containers",2223),("mtl",1817),("text",1270),("transformers",1155),("directory",1032),("filepath",969),("time",818),("array",687)] 1,941,217,280 bytes allocated in the heap 157,663,360 bytes copied during GC 9,957,384 bytes maximum residency (13 sample(s)) 182,664 bytes maximum slop 27 MB total memory in use (0 MB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause Gen 0 3728 colls, 0 par 0.18s 0.18s 0.0000s 0.0008s Gen 1 13 colls, 0 par 0.10s 0.10s 0.0079s 0.0127s TASKS: 4 (1 bound, 3 peak workers (3 total), using -N1) SPARKS: 0 (0 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled) INIT time 0.00s ( 0.00s elapsed) MUT time 0.81s (2205.36s elapsed) GC time 0.28s ( 0.28s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 1.09s (2205.64s elapsed) Alloc rate 2,401,538,990 bytes per MUT second Productivity 74.2% of total user, 0.0% of total elapsed gc_alloc_block_sync: 0 whitehole_spin: 0 gen[0].sync: 0 gen[1].sync: 0 real 36m45.647s user 0m47.507s sys 0m10.817s submitted by brooksbp
[link] [2 comments]
Categories: Incoming News

Use Haskell shared library with foreign exports withdlopen/dlsym

haskell-cafe - Mon, 09/08/2014 - 3:05pm
Hello Cafe, I am trying to use a Haskell shared library with foreign exports from Haskell again via dlopen/dlsym. Sadly it segfaults, and the segfaults happen on dlclose during garbage collection points (as figured out by monochrom in #haskell). So right now I can only open a library once and may not dlclose it. Can someone point me to a mistake I made, or is this rather a ghc (7.8.3) bug? Please see attached minimal example. Regards, Tobias test.hs: module Main where import qualified System.Posix.DynamicLinker as DL import Foreign foreign import ccall "dynamic" mkTest :: FunPtr Int -> Int main = do DL.withDL ("./libtest.so") [DL.RTLD_NOW] $ \dl -> do dimPtr <- DL.dlsym dl "test" let test = mkTest dimPtr print test libtest.hs: module Test() where import Foreign foreign export ccall test :: Int test :: Int test = 124 build with: ghc --make -shared -dynamic -fPIC libtest.hs -o libtest.so ghc --make -dynamic test.hs
Categories: Offsite Discussion

HTML5-compliant parsers and CSS selectors

Haskell on Reddit - Mon, 09/08/2014 - 3:02pm

I need to do two tasks, I'm searching for Haskell libraries to

  • Convert HTML documents on the wild to a DOM structure using the HTML5 parsing algorithm. This rules out xmlhtml but apparently - from a 2010 discussion - TagSoup qualifies as an HTML5 parser. Is this accurate?

  • Run CSS selectors on the resulting DOM. selectors from Hackage seem to qualify - but it seems to be based on xml-conduit, not sure how it compares to TagSoup (or whether they can be used together), but it seems to be about XML parsing, not HTML5. There's also dom-selector, and, what seems more promising, HXT combined with HandsomeSoup.

TagSoup can be interfaced with HXT using hxt-tagsoup. Is this the way to go? Should I use some other combination of libraries?

The code at the HandsomeSoup Github looks good and does what I want,

import Text.XML.HXT.Core import Text.HandsomeSoup main = do let doc = fromUrl "http://www.google.com/search?q=egon+schiele" links <- runX $ doc >>> css "h3.r a" ! "href" mapM_ putStrLn links

Is it easy to switch it to use hxt-tagsoup? (or rather, would it make sense?)

submitted by protestor
[link] [2 comments]
Categories: Incoming News

ANNOUNCE: buildable-0.1.0.0

haskell-cafe - Mon, 09/08/2014 - 2:32pm
Have you ever wanted to deal with the builders for various data types in a polymorphic/overloaded fashion? I'm needing to do so and couldn't find any existing code that did so, so I decided to rectify this: http://hackage.haskell.org/package/buildable As a (very contrived) example: λ> build ((365 :: Dec Int) <| fromValue (Char7 ' ') |> (365 :: BigEndian Int16) |> (" omega=
Categories: Offsite Discussion

Working with haskell in school

Haskell on Reddit - Mon, 09/08/2014 - 10:29am

So im a beginner with haskell and im currently working on an assignment with haskell in school and i have gotten stuck at this 5:

The assignments are here

I havent found anything on how to do it so i would love to get any help i can get.

I dont want you do to it for me i just want some help so i can solve it on my own

And something on assignment 5.1 would be great too

*edit: Cleaned up a bit and added a link to the assignment

submitted by Fassticman
[link] [4 comments]
Categories: Incoming News

The GHC Team: Haskell Implementors Workshop 2014 videos available!

Planet Haskell - Mon, 09/08/2014 - 9:55am

Without further ado, here's the ​HIW 2014 Youtube Playlist (kindly provided by Malcolm Wallace)

Categories: Offsite Blogs

introspection at runtime

Haskell on Reddit - Mon, 09/08/2014 - 9:41am

Can someone explain me why it is impossible to introspect into a function at runtime in Haskell?

submitted by felipeZ
[link] [6 comments]
Categories: Incoming News

FFI question

haskell-cafe - Mon, 09/08/2014 - 8:11am
Hello, I need memory refreshing about FFI because I need to fix a bug (plus I got down a rat hole because of Ukraine war :-(). Following a snippet of something I wrote:
Categories: Offsite Discussion

Jan Stolarek: Promoting functions to type families in Haskell

Planet Haskell - Mon, 09/08/2014 - 5:02am

It’s been very quiet on the blog these past few months not because I’m spending less time on functional programming but precisely for the opposite reason. Since January I’ve been working together with Richard Eisenberg to extend his singletons library. This work was finished in June and last Friday I gave a talk about our research on Haskell Symposium 2014. This was the first time I’ve been to the ICFP and Haskell Symposium. It was pretty cool to finally meet all these people I know only from IRC. I also admit that the atmosphere of the conference quite surprised me as it often felt like some sort of fan convention rather than the biggest event in the field of functional programming.

The paper Richard and I published is titled “Promoting Functions to Type Families in Haskell”. This work is based on Richard’s earlier paper “Dependently typed programming with singletons” presented two years ago on Haskell Symposium. Back then Richard presented the singletons library that uses Template Haskell to generate singleton types and functions that operate on them. Singleton types are types that have only one value (aside from bottom) which allows to reason about runtime values during compilation (some introduction to singletons can be found in this post on Richard’s blog). This smart encoding allows to simulate some of the features of dependent types in Haskell. In our current work we extended promotion capabilities of the library. Promotion is only concerned with generating type-level definitions from term-level ones. Type-level language in GHC has become quite expressive during the last couple of years but it is still missing many features available in the term-level language. Richard and I have found ways to encode almost all of these missing features using the already existing type-level language features. What this means is that you can write normal term-level definition and then our library will automatically generate an equivalent type family. You’re only forbidden from using infinite terms, the do-notation, and decomposing String literals to Chars. Numeric literals are also very problematic and the support is very limited but some of the issues can be worked around. What is really cool is that our library allows you to have partial application at the type level, which GHC normally prohibits.

You can learn more by watching my talk on YouTube, reading the paper or the singletons documentation. Here I’d like to add a few more information that are not present in the paper. So first of all the paper was concerned only with promotion and didn’t say anything about singletonization. But as we enabled more and more language constructs to be promoted we also made them singletonizable. So almost everything that can be promoted can also be singletonized. The most notable exception to this rule are type classes, which are not yet implemented at the moment.

An interesting issue was raised by Adam Gundry in a question after the talk: what about difference between lazy term-level semantics and strict type-level semantics? You can listen to my answer in the video but I’ll elaborate some more on this here. At one point during our work we were wondering about this issue and decided to demonstrate an example of an algorithm that crucially relies on laziness to work, ie. fails to work with strict semantics. I think it’s not straightforward to come up with such an algorithm but luckily I recalled the backwards state monad from Philip Wadler’s paper “The essence of functional programming”1. Bind operator of that monad looks like this (definition copied from the paper):

m `bindS` k = \s2 -> let (a,s0) = m s1 (b,s1) = k a s2 in  (b,s0)

The tricky part here is that the output of call to m becomes input to call to k, while the output of call to k becomes the input of m. Implementing this in a strict language does not at all look straightforward. So I promoted that definition expecting it to fail spectacularly but to my surprised it worked perfectly fine. After some investigation I understood what’s going on. Type-level computations performed by GHC are about constraint solving. It turns out that GHC is able to figure out in which order to solve these constraints and get the result. It’s exactly analogous to what happens with the term-level version at runtime: we have an order of dependencies between the closures and there is a way in which we can run these closures to get the final result.

All of this work is a small part of a larger endeavour to push Haskell’s type system towards dependent types. With singletons you can write type-level functions easily by writing their definitions using the term-level language and then promoting these definitions. And then you can singletonize your functions to work on singleton types. There were two other talks about dependent types during the conference: Stephanie Weirich’s “Depending on Types” keynote lecture during ICPF and Richard’s “Dependent Haskell” talk during Haskell Implementators Workshop. I encourage everyone interested in Haskell’s type system to watch both of these talks.

  1. The awful truth is that this monad does not really work with the released version of singletons. I only realized that when I was writing this post. See issue #94 on singletons bug tracker.
Categories: Offsite Blogs

ANNOUNCE: New Hackage release -LargeCardinalHierarchy-0.0.1

General haskell list - Sun, 09/07/2014 - 11:25pm
Shalom Fellow Haskellers, I just uploaded my first documented Hackage release, the LargeCardinalHierarchy.hs package. I wrote this program four years ago during my junior year of university. It is a simple transfinite cardinal arithmetic library for all large cardinals listed on the following Wikipedia page: http://en.wikipedia.org/wiki/List_of_large_cardinal_properties The documentation was generated using Haddock 2.11.0 and the source code was written under GHC 6.8.2. http://hackage.haskell.org/package/LargeCardinalHierarchy-0.0.1/src/LargeCardinalHierarchy.html Best, Stephen E. A. Britton _______________________________________________ Haskell mailing list Haskell< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell
Categories: Incoming News

A Netwire 5 Tutorial

Haskell on Reddit - Sun, 09/07/2014 - 10:34pm

I tried my hand at writing a tutorial for working with Netwire 5, GLFW, and OpenGL (primarily geared at the Netwire side). Some links:

Tutorial, and the GitHub referenced (and linked) in the post.

Any sort of feedback would be greatly appreciated -- grammatical mistakes, lack of clarity, being just plain run about a piece of my logic or code, anything. I want to get better at this kind of thing so I can give back to the community. Thanks for your time.

submitted by crockeo
[link] [4 comments]
Categories: Incoming News