News aggregator

Tim Docker: A New Charting API

Planet Haskell - Fri, 09/05/2014 - 11:34pm

One of the challenges with building a library like Chart is the tension between ease of use and flexibility. Users want to produce charts with a minimum of code up front, but later want to refine the details. The chart library addresses this through the use of "defaulted records" using Data.Default.Class. Because such records are often nested, we rely on the somewhat intimidating lens library to modify the default values. We end up with code to create chart elements like this:

sinusoid2 = plot_points_title .~ "fn(x)" $ plot_points_values .~ mydata $ plot_points_style . point_color .~ opaque red $ def

This is much simpler and cleaner that the corresponding code using native record accessors, but it still has a certain amount of syntactic overhead.

I’ve added a simple state monad to the library to further clean up the syntax. The state of the monad is the value being constructed, allowing the use of the monadic lens operators. The above code sample becomes:

sinusoid2 = execEC $ do plot_points_title .= "fn(x)" plot_points_values .= mydata plot_points_style . point_color .= opaque red

This may seem only a minor syntactic improvement, but it adds up over an typical chart definition.

A few other changes further reduce the clutter in charting code:

  • A new Easy module that includes helper functions and key dependencies
  • Simpler "toFile" functions in the rendering backends
  • Automatic sequencing of colours for successive plots

All this means that a simple plot can now be a one liner:

import Graphics.Rendering.Chart.Easy import Graphics.Rendering.Chart.Backend.Cairo mydata :: [Double,Double] mydata = ... main = toFile def "test.png" $ plot $ points "lines" mydata

But this extends naturally to more complex charts. The code differences between the new stateful API versus the existing API can been seen in this example.

The stateful API is available in chart v1.3 It is a thin layer over the existing API – both will be continue to be available in the future.


Categories: Offsite Blogs

Can't create a static Linux executable when usinghmatrix

haskell-cafe - Fri, 09/05/2014 - 10:02pm
Hi Cafe, I am trying to build a static exec to be run on another machine, and I failed probably due to hmatrix. How can I fix this? Thanks! Test code: import Numeric.LinearAlgebra.Data main = print (fromLists [[2,3,3], [2,3,3]] :: Matrix Double) When complied with "ghc -O2 -static -optc-static -optl-static test.hs -optl-pthread", gave me lots of errors: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblapack.a(dgees.o): In function `dgees_': (.text+0xbc4): undefined reference to `dcopy_' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblapack.a(dgees.o): In function `dgees_': (.text+0xed9): undefined reference to `dswap_' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblapack.a(dgees.o): In function `dgees_': (.text+0x1304): undefined reference to `dswap_' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblapack.a(dgees.o): In function `dgees_': (.text+0x1377): undefined reference to `dswap_' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblapack.a(dgeev.o): In function `dg
Categories: Offsite Discussion

Dependent Haskell

Haskell on Reddit - Fri, 09/05/2014 - 7:17pm
Categories: Incoming News

IDE for Haste projects

Haskell on Reddit - Fri, 09/05/2014 - 10:36am
Categories: Incoming News

Presentation about monads (beginner level) with example code

Haskell on Reddit - Fri, 09/05/2014 - 8:49am

Hi!

I gave a presentation about monads at a Hungarian Haskell meetup in February. I put an emphasis on examples over definitions. My code examples include ones about image processing and text-based adventure games.

I'm not a Haskell expert, I just wanted to give a different perspective about starting out with monads so don't expect anything high level.

Audience members said they've found my presentation informative; I hope you will too.

Presentation: https://www.youtube.com/watch?v=ze0SGPOcfTM

Code examples: https://github.com/printron/feb-2014-monad

submitted by printron
[link] [comment]
Categories: Incoming News

How can I specify a "must not be a member of a certain type class" as a constraint?

Haskell on Reddit - Fri, 09/05/2014 - 2:20am

I'm trying to implement a typeclass hierarchy and want to specify that a type can only implement one of two classes in a branch of the heirarchy. How would I go about doing that?

submitted by deltaSquee
[link] [29 comments]
Categories: Incoming News

Anecdotes and Advice on Hiring Junior or Summer/Co-Op Students for Haskell Work

Haskell on Reddit - Thu, 09/04/2014 - 11:56pm

I've seen anecdotes about Haskell's type system being very beneficial for juniour programmers working in a team environment (I think one from Don Stewart); that leaning on the type system allows juniour engineers to become productive faster while also keeping teams more productive.

My conjecture is that Haskell creates a really good environment for junior engineers. Yes, there is a steeper learning curve, but productivity should be increased (for them and the rest of the team) and anxiety lessened by leaning on the compiler and purity to guide programmers on the right course. Alas, this is just conjecture.

I'm wondering if anyone has any experience or anecdotes in this area. Especially with respect to hiring summer co-op students for paid work. This is quite an important consideration for start-ups in University/College towns who rely on Co-Op students. Specifically:

  1. Was it hard to hire junior programmers to write Haskell? (i.e. do young coders know about Haskell and/or see the appeal)
  2. Is writing Haskell appealing to juniour / co-op students?
  3. Are junior programmers able to learn Haskell quick enough? Can they become productive in Haskell in a short, summer-long co-op? How long did it take?
  4. Any tips or advice on interviewing junior / co-op programmers?
  5. What didn't work? What did?

Thanks!

submitted by aaronlevin
[link] [29 comments]
Categories: Incoming News

Elm-like IDE for Haste projects

haskell-cafe - Thu, 09/04/2014 - 9:23pm
Following the thread on lightweight Web interfaces for Haskell: http://permalink.gmane.org/gmane.comp.lang.haskell.cafe/112586 I finished an Elm-like IDE for Haste projects. The software is at: https://github.com/agocorona/tryhplay Running in a heroku instance: http://tryplayg.herokuapp.com Besides to edit-compile and run, it can also import , compile and run haste projects from git repositories (Although this, like the rest of the project is experimental). I use it for my hplayground framework but it can run any haste project. Using playground is easy to translate console programs to the browser and have reactive effects A simple example: http://tryplayg.herokuapp.com/try/console.hs/edit the hello-haste example: http://tryplayg.herokuapp.com/try/hello-haste.hs/edit Or something more complicated: the todo application, from todoMVC.com written in Haste and hplayground: http://tryplayg.herokuapp.com/try/todo.hs/edit rename the programs if you modify them. Follow the instructions to download the
Categories: Offsite Discussion

Cabal and Hackage are down?

Haskell on Reddit - Thu, 09/04/2014 - 8:24pm

Does anyone know anything about this?

submitted by jprider63
[link] [23 comments]
Categories: Incoming News

Parallel evaluation of code dependencies

haskell-cafe - Thu, 09/04/2014 - 7:00pm
Hi Cafe, Suppose that I have a representation of a DSL in Haskell (a physical number crunching simulation using quasiquoting for instance) and I want to evaluate the resulting Haskell representation by splitting it into chunks and send these chunk to some cluster, a supercomputer, etc. It doesn't matter for the moment the distribution protocol. My advisor suggested me that the best way of doing such a thing, is through a call by value strategy. Where I simply evaluate in parallel all the arguments of the functions. The problem with this alternative is that I must manipulate the Haskell representation and use some library ( or write some code) to identify the dependencies and evaluate them in parallel. Can please someone suggest me the best way to tackle this problem? I really appreciate any help. Felipe Z. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

bos/criterion · GitHub

del.icio.us/haskell - Thu, 09/04/2014 - 6:31pm
Categories: Offsite Blogs

diagrams fails to install

haskell-cafe - Thu, 09/04/2014 - 6:06pm
Hello, I'm trying to install Diagrams on FreeBSD 10. It fails thus: cabal install diagrams Resolving dependencies... Configuring arithmoi-0.4.1.1... Building arithmoi-0.4.1.1... Preprocessing library arithmoi-0.4.1.1... [ 1 of 34] Compiling Math.NumberTheory.Primes.Sieve.Indexing ( Math/NumberTheory/Primes/Sieve/Indexing.hs, dist/build/Math/NumberTheory/Primes/Sieve/Indexing.o ) <no location info>: Warning: Couldn't figure out LLVM version! Make sure you have installed LLVM ghc: could not execute: opt Failed to install arithmoi-0.4.1.1 cabal-install: Error: some packages failed to install: arithmoi-0.4.1.1 failed during the building phase. The exception was: ExitFailure 1 diagrams-1.2 depends on arithmoi-0.4.1.1 which failed to install. diagrams-contrib-1.1.2.1 depends on arithmoi-0.4.1.1 which failed to install. ghc --info reports: [("Project name","The Glorious Glasgow Haskell Compilation System") ,("GCC extra via C opts"," -fwrapv") ,("C compiler command","gcc47") ,("C compil
Categories: Offsite Discussion