News aggregator

GHC 7.10 breakage with FlexibleInstances

Haskell on Reddit - Thu, 05/28/2015 - 2:13pm (I accidentally wrote FlexibleContexts in the lpaste title instead of FlexibleInstances).

Works just fine using ghc-7.8. Fails with No instance for (FromJSON Bar) using ghc-7.10.

I don't know why it works in either of them, since I didn't explicitly turn on OverlappingInstances.

But check this out. If we swap the let binding for a monadic binding

... for some reason this works just fine in ghc 7.10. Something sketchy is going on here.

submitted by drb226
[link] [8 comments]
Categories: Incoming News

Roman Cheplyaka: How to force a list

Planet Haskell - Thu, 05/28/2015 - 2:00pm

Let’s say you need to force (evaluate) a lazy Haskell list.

A long time ago, this was a common way to fight lazy I/O: you read a String and then force it. These days you can have normal I/O with strict Text or ByteString instead.

Anyway, let’s say you do need to force a list. This came up in a pull request for lexer-applicative. Another scenario is if you want to evaluate a lazy Text or ByteString without copying the chunks. Or, you know, for any other reason.

First of all, how exactly do you want to force it? There are two primary ways: force the spine or force the elements too. (You can’t force the elements without forcing the spine.)

Forcing the spine means forcing all cons cells without touching the elements. One way to do that is to evaluate the length of the list, but that feels ad-hoc because it computes the result that is not needed. Here’s an elegant way to walk the spine:

forceSpine :: [a] -> () forceSpine = foldr (const id) ()

(Obviously, you need to force the resulting () value, by calling evaluate or seq-ing it to something else, for any evaluation to take place.)

const id, also known as flip const, returns its second argument while ignoring the first. So the evaluation goes like this:

forceSpine [x1, x2] = foldr (const id) () [x1, x2] = (const id) x1 $ foldr (const id) () [x2] = foldr (const id) () [x2] = (const id) x2 $ foldr (const id) () [] = foldr (const id) () [] = ()

See how forceSpine “unpacks” the list (thus forcing the spine) and throws all elements away.

I mentioned that you may also want to force the elements of the list, too. Most of the time you want to deep-force them, and so you should just rnf the whole list. Even when the elements are atomic (like Char or Int), evaluating them to weak head normal form is still equivalent to rnf.

But occasionally you do want to shallow-force the elements. In that case, simply replace const id with seq in the definition of forceSpine to obtain forceElements:

forceElements :: [a] -> () forceElements = foldr seq ()

Again, looking at the evaluation chain helps to understand what’s going on:

forceElements [x1, x2] = foldr seq () [x1, x2] = seq x1 $ foldr seq () [x2] = foldr seq () [x2] = seq x2 $ foldr seq () [] = foldr seq () [] = ()

Same as before, only elements get forced before being thrown away.

And here’s a table that may help you understand better the difference between seq, forceSpine, forceElements and rnf:

list `seq` () forceSpine forceElements rnf [Just True] () () () () [Just undefined] () () () undefined [undefined] () () undefined undefined True : undefined () undefined undefined undefined undefined undefined undefined undefined undefined

Since forceSpine and forceElements are based on foldr, they can be trivially generalized to any Foldable container, with the caveat that you should understand how the container and its Foldable instance work. For example, forceSpine is useless for Data.Map.Map, since it is already spine-strict, and forceElements for a tuple will only force its second element.

Categories: Offsite Blogs

The Haskell REPL seems awfully complex for a beginner to use

Haskell on Reddit - Thu, 05/28/2015 - 12:39pm

Reading through various tutorials online (LYAH, CIS194, etc) I'd like to be able to fire up a REPL and play along, but it seems like the REPL plays by different rules. Just trying to define a simple function in the REPL, I go to SO and see responses such as "It's because ghci executes in the IO monad, so you need to use let to bind non-IO values." Huh? I don't know what a monad is yet, I'm just trying to figure out pattern matching!

Am I the only newbie who is puzzled by this? By constrast, the REPL for other languages I've used, including Ruby, Python, Clojure, and JS, seem super easy to use and ready-to-go. Is the Haskell REPL mainly a power users tool among community members or something?

submitted by thecity2
[link] [59 comments]
Categories: Incoming News

International Conference on Live Coding, 13-15 July,Registration open

haskell-cafe - Thu, 05/28/2015 - 11:36am
First International Conference on Live Coding ICSRiM, School of Music, University of Leeds 13th-15th July 2015 We are happy to announce that registration for ICLC2015 is now open. Live coding turns programming languages into live interfaces, allowing us to directly manipulate computation via its notation. Live coding has great potential, being used for example to create improvised music and visuals, to allow developers to collaborate in new ways, to better understand computational models by making fundamental changes to them on-the-fly, and to find new ways to learn and teach programming. Since the beginning of the TOPLAP movement in 2003 (building on an extensive but hidden pre-history), live coding has grown fast, attracting interest from many people in artistic, creative, scientific, educational, business and mixed contexts. After a good number of international events, the time is right to bring these people together for an academic conference, exchanging ideas and tec
Categories: Offsite Discussion

GHC + musl = easier static linking

Haskell on Reddit - Thu, 05/28/2015 - 11:23am

TL;DR: I made some GHC binaries for linux that rely on musl instead of glibc for easier static linking. Scroll down for the link.

As most of you know, musl is a linux only C standard library that is optimized for static linking. Statically linked binaries can simplify distribution and deployment. If you have tried to statically link a program with glibc, you will probably know that this does not always work as expected: for example, in many cases the resulting binary will require to be executed in a system that has the exact same version of glibc as the one that was used to compiled it. In essence, static binaries linked with glibc are oftentimes less portable than dynamic ones.

I decided to see if I could use GHC with musl. The problem was that while I could find some references online, I could not find a precompiled version of GHC that uses musl. So I decided to try and a build one myself. I was able to successfully bootstrap GHC under musl and I am posting it today in case someone else finds it useful:

Google Drive

I posting this on google drive, I have no better place to host this, hopefully google will not disable my account :-) This is a fully bootstrapped (i.e. stage 2) GHC and not a cross compiler. So this will not work in a typical glibc based linux distribution. You need a complete musl based environment to use it. Also, the binaries produced by this GHC will all depend on musl and not work on most glibc based distros. On the other hand, statically compiled binaries should be very portable and will not depend on any particular C standard library. I have done some minimal testing and it seems to work rather well; everything I tried to compile from hackage just worked. Additionally it can compile GHC itself which is always a good test. The size of the resulting static binaries is acceptable. In my 64 bit system, a simple hello world has the following sizes (stripped): 800K glibc dynanic, 1648K glibc static, and 1012K musl static.

Why not use a cross-compiler? I have found that in practice it is easier to have a separete environment for producing static binaries. A cross-compiler requires that you also cross-compile all the C libraries that you use. Additionally, cabal has still problems with cross-compiling and will not work out of the box.

Note that musl is not 100% compatible with glibc, so some things might work slightly differently.

If you do not like using a GHC precompiled by someone else, you can use my binaries to compile GHC under musl yourself; it would be easier than cross-compiling GHC from scratch.

EDIT: I posted some notes on github. There you can also find binaries for a (mostly working) port of GHC to uClibc.

submitted by redneb8888
[link] [15 comments]
Categories: Incoming News


haskell-cafe - Thu, 05/28/2015 - 9:26am
Deferring type errors until runtime is a feature which probably helps a lot with the adoption of Haskell. Newcomers can get the encouragement of a mostly-working program even if there are type errors in a few places. I can write foo = 1 + 1 bar = head True main = print foo and still run the program or load it in GHCi. Does anyone think it would also be beneficial to have "-fdefer-name-errors"? If I write foo = 1 + 1 bar = baz main = print foo but baz doesn't exist it would still be nice to let the program run or be loaded in GHCi. This could be achieved by replacing all missing variables by "error 'baz was not defined'" or similar. If a suitable parser could be written it might even be possible to defer syntax errors! This kind of thing would make the experience with Haskell gentler for newcomers, but also more pleasant for veterans! Tom
Categories: Offsite Discussion

PhD Studentship in heterogeneous computing

Haskell on Reddit - Thu, 05/28/2015 - 7:57am

PhD Studentship in the area of applying type theory and systems design to formalize the execution model heterogeneous computing. Within the group we already have a intermediate language for SIMT execution models with a compiler and tools being developed in Haskell and formalized in Agda and it is hoped that the successful applicate would continue to work in this area.

Please feel free to contact me for more information.

submitted by cuberoo
[link] [3 comments]
Categories: Incoming News

Announcing lambda prover

Haskell on Reddit - Thu, 05/28/2015 - 7:19am
Categories: Incoming News

Haskell and Web Frameworks/Servers

Haskell on Reddit - Thu, 05/28/2015 - 7:04am

Hello, I have a project where I want to have servers that are easily reproducible. That is, many copies of the same structure that can communicate between themselves and also offer the same services. As Haskell is the language I'm more familiar with, it would be nice to be able to do it with it, but that brings questions:

  • Are there frameworks that are more mature than others? I really need them to be robust. Same question for servers.

  • The fact that they are Haskell based make them more difficult to install/build in other servers? Using Stackage would be a good step? What would optimize the reproducibility of the system?

Thank you!

submitted by guaraqe
[link] [5 comments]
Categories: Incoming News

How to force a list

Haskell on Reddit - Thu, 05/28/2015 - 5:35am
Categories: Incoming News

The evolution of Rust

Lambda the Ultimate - Thu, 05/28/2015 - 3:12am

Graydon Hoare is the original developer of Rust even before Mozilla adopted it. For the 1.0 release he prepared a lightning talk on how the language changed over 10 years.
He only published some bullet points, but the topic list is interesting as well.

  • Six ways Rust is fundamentally different from how it started
  • Six ways Rust is fundamentally the same as how it started
  • Six things we lost along the way
  • Six things we gained along the way
  • Six things I'm irrationally, disproportionately pleased by

Read the full blog post for the content of the five lists.

Categories: Offsite Discussion

-fdefer-scope-errors, anyone?

Haskell on Reddit - Thu, 05/28/2015 - 3:03am

Similar to -fdefer-type-errors, it would sometimes be convenient to defer scope errors, for the same reasons: making a breaking change and then testing bits and pieces of it, rather than having to try and fix everything all at once before getting past the compilation phase.

Along the same vein, -fdefer-template-haskell-errors? -fdefer-all-the-things?

Has this been proposed yet?

submitted by drb226
[link] [9 comments]
Categories: Incoming News

foldt fix proposal (HaskellWiki)

haskell-cafe - Wed, 05/27/2015 - 11:05pm
hi ALL, I think I've found a mistake in foldt implementation on the Fold page[1] of the HaskellWiki. foldt :: (a -> a -> a) -> a -> [a] -> a foldt f z [] = z foldt f z [x] = x -- mistake?
Categories: Offsite Discussion

how to organize a parallel parser/compiler

haskell-cafe - Wed, 05/27/2015 - 10:27pm
hello haskell-cafe, suppose you have a compiler pipeline roughly similar to (from write you a Haskell <> ): modl :: FilePath -> L.Text -> CompilerM () modl fname = parseP fname >=> dataP >=> groupP >=> renameP >=> desugarP >=> inferP >=> evalP and suppose you have a language where you can compile multiple files and compilation must be made _as if_ files were concatenated together in the order given on the command line (there might be side effects that affect parsing of subsequent files); still in the average case there're no dependencies and files could be compiled in parallel (or some of the dependencies can be handled at the AST level as one can prove they don't affect parsing but only aspects of the AST that can be patched). What are good strategies for dealing with this and rerun some of the parseP functions (and in the simplest solution the complete pipeline after it). The strategy I have in mind now doesn't mix well with the above pipeli
Categories: Offsite Discussion

CoPro 2015 - Mini-Symposium on Coordination Programming

General haskell list - Wed, 05/27/2015 - 10:25pm
*************************************************************************** CALL FOR PAPERS CoPro 2015 Mini-Symposium on Coordination Programming Edinburgh, UK September 1, 2015 Submission deadline: July 3, 2015 *************************************************************************** PART OF ParCo 2015 17th International Conference on Parallel Computing Edinburgh, UK September 1-4, 2015 *************************************************************************** Coordination programming is a term that everybody seems to have a v
Categories: Incoming News

pqueue - repository and maintainer (taking over)

haskell-cafe - Wed, 05/27/2015 - 9:01pm
Greetings, Regarding the pqueue package: 1) Does anyone have any (additional) contact details for the current maintainer/author, Louis Wasserman? 2) Is the package's repository available anywhere? The darcs link listed in the package 404s. 3) I would be willing to take over for basic maintenance if the current maintainer is unavailable. The pqueue package does not compile with ghc-7.10. Fixing requires just some quick changes (i have a working version locally). The last upload for the package is from 2012, but the author's github account lowasser shows some more recent activity. Yet I have not received a reply to my e-mail from six weeks ago. Lennart
Categories: Offsite Discussion

ZeroMQ Thread Safety

haskell-cafe - Wed, 05/27/2015 - 7:30pm
Hi all, According to the ZeroMQ docs[1]: "Individual ØMQ sockets are not thread safe except in the case where full memory barriers are issued when migrating a socket from one thread to another." The Haskell ZeroMQ binding [2] is a fairly thin wrapper around the C API, and in particular doesn't seem to do much to enforce thread safety as described above. My question: do I need to use bound threads to call functions on sockets to ensure that all the foreign calls happen on the same OS thread, or is it the case that two consecutive foreign calls in a single Haskell thread have a "full memory barrier" between them if they end up being called from different OS threads? Thanks in advance, David [1] [2] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion