News aggregator

2, 3, 4 Trees

Haskell on Reddit - Thu, 12/11/2014 - 4:44am

I am looking for a display function for 2,3,4 Tree in Haskell. I have all the other parts coded like search, addNode etc.

If anyone could help that would be great. My display is only on one line but I need to display it a tree like fashion.

submitted by SmartBruteAttack
[link] [21 comments]
Categories: Incoming News

Home » Galois, Inc. - Wed, 12/10/2014 - 7:50pm
Categories: Offsite Blogs

Home » Galois, Inc. - Wed, 12/10/2014 - 7:50pm
Categories: Offsite Blogs

Oliver Charles: 24 Days of GHC Extensions: Implicit Parameters

Planet Haskell - Wed, 12/10/2014 - 6:00pm
> {-# LANGUAGE ImplicitParams #-} > import Data.Char

Yesterday we looked at nullary type classes - type classes that don’t vary over any types - and saw how they can be used to leave part of a program undefined. Our particular example looked at building a library that needs to call a logging function, but we leave the implementation up to the library author.

However, using a nullary type class for this has some drawbacks - the biggest is that we are now tied to a single choice of logging function. This can be problematic if we ever need to vary what it means to log throughout the life time of a program. This may crop up if we decide that we need to transform or discard log entries at smaller parts of our program.

To solve this, lets rewrite our library to take logging as a parameter to a function:

> type LogFunction = String -> IO () > > type Present = String > > queueNewChristmasPresents :: LogFunction -> [Present] -> IO () > queueNewChristmasPresents logMessage presents = do > mapM (logMessage . ("Queueing present for delivery: " ++)) presents > return ()

This isn’t much different from what we saw yesterday, but it quickly becomes painful to use in practice. Whenever we want to abstract over queueNewChristmasPresents, we have to either choose to commit to a specific log function, or we have to manually propagate the LogFunction to the parent function.

One solution might be to move the LogFunction to a reader monad, but this still carries a cost and the program will need to be transformed. A less invasive technique is to use an implicit parameter.

Implicit parameters act like parameters to a function, except the caller never has to apply the function to the argument. Instead, the argument is automatically passed to the function by merely being in scope. Let’s see how this works out for our logger:

> queueNewChristmasPresents2 :: (?logMessage :: LogFunction) => [Present] -> IO () > queueNewChristmasPresents2 presents = do > mapM (?logMessage . ("Queueing present for delivery: " ++)) presents > return ()

As you can see, something interesting has happened. The LogFunction is no longer a parameter to the function, but is rather part of the context of the function - constraints that must be satisfied when we use the program. The body of the program is mostly the same, other than the leading ? that prefixes implicit parameters.

To supply an implicit parameter, all we need to do is bring an appropriately named variable into scope:

> ex1 :: IO () > ex1 = > let ?logMessage = \t -> putStrLn ("[XMAS LOG]: " ++ t) > in queueNewChristmasPresents2 ["Cuddly Lambda", "Gamma Christmas Pudding"] .> ex1 [XMAS LOG]: Queueing present for delivery: Cuddly Lambda [XMAS LOG]: Queueing present for delivery: Gamma Christmas Pudding

Perfect, we’ve got the same type of programs as we saw yesterday!

However, we now have the ability to use two different types of loggers in the same program:

> ex2 :: IO () > ex2 = do > -- Specifies its own logger > ex1 > > -- We can locally define a new logging function > let ?logMessage = \t -> putStrLn (zipWith (\i c -> if even i > then c > else toUpper c) > [0..] > t) > queueNewChristmasPresents2 ["Category Theory Books"] [XMAS LOG]: Queueing present for delivery: Cuddly Lambda [XMAS LOG]: Queueing present for delivery: Gamma Christmas Pudding QUeUeInG PrEsEnT FoR DeLiVeRy: CaTeGoRy THeOrY BoOkS


Implicit parameters are something of a love-hate extension, to the best of my knowledge - though it can be mighty useful sometimes. Also, as with many aspects of Haskell - it is useful for things that were never even anticipated. Tom Ellis has a blog post that demonstrates how one can “fake” a module system by using implicit parameters.

This post is part of 24 Days of GHC Extensions - for more posts like this, check out the calendar.

Categories: Offsite Blogs


Haskell on Reddit - Wed, 12/10/2014 - 3:32pm

An experiment in Haskell web services. Runs quicksort on a mutable array (using a heap to repeatedly partition the smallest available interval) and pushes 'swap' and 'partition' events to the client via websocket for visualization using D3.js.

Running on Heroku at:


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

Neil Mitchell: Beta testing the Windows Minimal GHC Installer

Planet Haskell - Wed, 12/10/2014 - 3:27pm

Summary: There is now a minimal Windows GHC installer that can install the network library.

Michael Snoyman and I are seeking beta testers for our new Windows GHC installer. The installer is very new, and we're keen to get feedback.

Update: If you want to install to Program Files (the default installation path), download the file, right click and hit "Run as administrator". This will be automatic in the next version.

One of the standard problems when upgrading Haskell libraries on Windows is that sometimes you have to upgrade a package which requires a configure script - typically the network library. When that happens, you have to take special measures, and even then, sometimes the binary will fail at runtime (this happens on about half my machines).

Our installer solves that problem by bundling GHC, Cabal and MSYS in one installer. You can install the network library out of the box without any special configuration and it just works.

Our installer does not provide all the packages included with the Haskell Platform, but it does provide an environment where you can easily install those packages. This minimal installer might be more suitable for developers.

Why might I want this installer

The installer is much easier to install than the GHC distribution (has a real installer, sets up the %PATH%, includes Cabal and can build the network library).

The installer has less libraries than the Haskell Platform installer, but includes MSYS so you can build everything in the Platform. The lack of additional packages and close correspondence with GHC (there is one installer for each GHC version) might make it more suitable for library developers. Once GHC 7.10.1 is released, we hope to make a GHC Minimal Installer available within days.

The installer also has more precise control over what is added to the %PATH%. You can add all the binaries it provides, or just add a single binary minghc-7.8.3 which when run at the command prompt temporarily adds all the installed binaries to the %PATH%. Using the switcher, you can easily switch GHC versions.

Categories: Offsite Blogs

Compose Conference Registration Now Open [NYC, Jan 30 - Feb 1]

Haskell on Reddit - Wed, 12/10/2014 - 12:50pm


Call for Participation

Compose Conference 2015

January 30 - February 1, 2015 New York, NY


The practice and craft of functional programming :: Conference

Compose is a new conference for typed functional programmers, focused specifically on Haskell, OCaml, F#, SML, and related technologies.

Typed functional programming has been taken up widely, by industry and hobbyists alike. For many of us it has renewed our belief that code should be beautiful, and that programming can be as enjoyable as it is practical. Compose is about bringing together functional programmers of all levels of skill and experience — from technical leads to novices, and from long-time hackers to students just getting started.

It will feature a Friday night keynote by Stephanie Weirich on dependent type theory, a Saturday of great talks and presentations, and a Sunday unconference and code-in with hacking, tutorials, and mentoring.

In the days before and after Compose (Jan. 29-30 and Feb. 2-3), Well-Typed and Skills Matter are organizing commercial, paid Haskell tutorials by Duncan Coutts. Further information is available on the Well-Typed blog:

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

JP Moresmau: Using Ansi console for nicer console output in EclipseFP

Planet Haskell - Wed, 12/10/2014 - 10:24am
A little tip from the trenches (-:. I use the Ansi Console plugin in EclipseFP to be able to see a nice color output from my Haskell executable runs.

For example, the Tasty example:

Works also for Yesod applications, etc.

Note that some support for Tasty is being added in EclipseFP 2.6.3, to at least provide some templates for the cabal test-suite section and test modules. I'm not too sure if it's worth to develop a runner for it, since contrary to HTF we won't have a link to the source, so the standard output is probably nice enough.

Happy Haskell Hacking!

Categories: Offsite Blogs


Haskell on Reddit - Wed, 12/10/2014 - 10:19am
Categories: Incoming News