News aggregator

GHC plans for 7.10.1

Haskell on Reddit - Fri, 07/04/2014 - 5:57pm
Categories: Incoming News

Ken T Takusagawa: [mvoghuaz] One-dimensional puzzle generator

Planet Haskell - Fri, 07/04/2014 - 5:12pm

Here is a one-dimensional jigsaw puzzle generator implemented in Haskell, creating one-dimensional instances of the exact cover problem.

For generation purposes, the one-dimensional field is divided into n blocks each of size b.  Each of the n pieces is roughly centered on a unique block and spans at most p blocks.  The arguments to the program are b p n.

Each generated piece is specified by a list of coordinates offset from its leftmost coordinate.  Each individual piece is typically not contiguous; that would make the puzzle trivial to solve. Solve the puzzle by finding the offset of each piece in the field so that the field is exactly covered by all the pieces.

There is a "edge effect" flaw such that pieces near the edge tend to span less than p blocks.

Example run with parameters 10 5 10:
Pieces are:

Solution is the concatenation of:

Motivation is to generate random inputs to Knuth's Dancing Links DLX algorithm.  What puzzle parameters generate difficult puzzles?

Categories: Offsite Blogs

Robin KAY: HsQML released

Planet Haskell - Fri, 07/04/2014 - 3:36pm
I've been meaning start blogging again for ages, and this seemed to be as good a time as any. I've just released HsQML and uploaded it to Hackage. This minor point release fixes two issues:

Firstly, API changes in Cabal 1.18 broke HsQML's rather involved Setup.hs. I didn't want mandate that users have the latest Cabal library, so I investigated a couple of different options for supporting both the old and new. There are no really pretty solutions here and I ended up using Template Haskell to select between two different sets of utility functions.

Secondly, the text package has recently gone through two major version changes under the PVP. I've widened the Cabal version constraint to permit both text-1.0 and text-1.1.

Hope you enjoy!

release- - 2014.01.18

* Added support for Cabal 1.18 API.
* Relaxed Cabal dependency constraint on 'text'.
Categories: Offsite Blogs

Robin KAY: HsQML released

Planet Haskell - Fri, 07/04/2014 - 3:35pm
Yesterday, I made new a minor release of HsQML in order to address two issues with using it interactively via GHCi. As usual, it's available for download from Hackage. One little mistake did slip in however, in that I forget to change the darcs repository listed in the package cabal file to the Qt 4 branch. The main trunk is now being used for porting to Qt 5.

An explanation of the GHCi problems follows:

GHCi has traditionally had a number of limitations owing to the built-in linker it uses to load static object files dynamically. The linker is capable enough to load the output of GHC and any simple FFI C code that might be included in a library, but it can't cope with some of the relocations emitted by a C++ compiler. Originally, it wasn't even capable of reading the same archive libraries used by the GHC compiler for linking, and required that Cabal produce special compounded object files for it to use.

The C++ limitation was an issue for HsQML because Qt is a C++ library and hence HsQML needs to include some C++ code as part of its binding layer. I made use of the fact that GHCi depended on special object files in order to incorporate a workaround especially for GHCi. HsQML's build script modifies the build process by removing the objects containing C++ code from being compounded into the special object file, and places them into a separate shared library which is then referenced by the package's extra-ghci-libraries field. GHCi will hence load the shared library and the compiled C++ code within using the system linker, thereby avoiding the problems with its own.

However, it came to my attention recently* than this strategy had run into trouble as GHCi can now load regular archive libraries directly, supplanting the need for special object files. I discovered that the Fedora Linux had modified their distribution of GHC to disable generating the GHCi objects by default. Furthermore, that this behaviour would become the new standard default with Cabal 1.18. This broke HsQML with GHCi because because the aforementioned workaround didn't apply to the regular archive libraries and so GHCi's linker couldn't handle the C++ object files contained within.

I didn't want to simply apply the same workaround to the archive libraries as to the GHCi ones because that would introduce dealing with an additional magic shared library to users who simply wanted to compile their applications. The modification I've applied for this release was therefore to add code to Setup.hs to force (re-)enable generating the special GHCi object files under certain circumstances.

The impact of this issue is likely to decrease over time as GHC now also supports producing shared libraries from Haskell code in addition to static ones. This means that, going forward, the entirety of HsQML can be built as a shared library and GHCi can load it using the system linked without difficulty. My understanding is that this behaviour will become the default with GHC 7.8 for platforms other than Windows.

Hence, the rule is that generating GHCi object files is only force enabled if shared libraries are not enabled. The forcing behaviour can be disabled by passing -f-ForceGHCiLib to cabal-install.

The other issue I found that's fixed with this release is that GHCi had problems finding the workaround shared library on Windows. Unlike other platforms, the extra-ghci-libraries field needed to include the "lib" prefix to the referenced library name in order for Windows GHCi to find it without the library being on the PATH. With that fixed, HsQML should now work with GHCi out of the box on all platforms.

Now, back to working on the Qt 5 port!

release- - 2014.02.01

* Added mechanism to force enable GHCi workaround library.
* Fixed reference name of extra GHCi library on Windows.
* Thanks to rnons.
Categories: Offsite Blogs

Robin KAY: Using the Connections element with HsQML

Planet Haskell - Fri, 07/04/2014 - 3:35pm
I was asked recently if the Connections element could be used to declaratively connect QML actions to signals defined in Haskell code. I wasn't completely sure if it would work off-hand so I wrote the following example program with HsQML 0.2.x to find out (Hint: the answer is yes).

To begin with, we need a Haskell program which will load a QML document and fire off some signals. The following program forks off a thread which blocks for the user to enter a new line in the terminal window and fires a signal every time they do. The context object has two members, the signal we're experimenting with and a property called 'self' whose function will become apparent shortly.

{-# LANGUAGE DeriveDataTypeable, TypeFamilies #-}
import Graphics.QML
import Data.Typeable
import Data.Tagged
import Control.Concurrent
import Control.Monad

main :: IO ()
main = do
    ctx <- newObject MainObject
    tid <- forkIO $ forever $ do
        putStrLn "Press ENTER to run animation"
        void $ getLine
        fireSignal (Tagged ctx ::
            Tagged TheSignal (ObjRef MainObject))
    runEngineLoop defaultEngineConfig {
        contextObject = Just $ anyObjRef ctx}
    killThread tid

data TheSignal deriving Typeable
instance SignalKey TheSignal where
    type SignalParams TheSignal = IO ()

data MainObject = MainObject deriving Typeable
instance Object MainObject where
    classDef = defClass [
        defPropertyRO "self" ((\x -> return x) ::
            ObjRef MainObject -> IO (ObjRef MainObject)),
        defSignal (Tagged "theSignal" ::
            Tagged TheSignal String)]
The QML document to accompany the above program follows below. It should be placed in a file called 'main.qml' in order to be loaded by the defaultEngineConfig. You could set the initialURL field to something else if you wanted, but I'm trying to keep the code short.

import Qt 4.7
Rectangle {
    id: root
    width: 500; height: 500
    color: "red"
    Rectangle {
        id: square
        x: 150; y: 150; width: 200; height: 200
        color: "yellow"
        Rectangle {
            width: 50; height: 50; color: "black"
        transform: Rotation {
            id: rotateSquare
            origin.x: 100; origin.y: 100; angle: 0
        NumberAnimation {
            id: rotateAnim
            target: rotateSquare; property: "angle"
            from: 0; to: 360; duration: 1500
        Connections {
            target: self
            onTheSignal: rotateAnim.start()
The code for the Connections element is highlighted in bold. Of its two attributes, the first, called 'target', specifies the object with signals that we want to bind handlers to. In this example the signal is a member of the global object and this complicates matters because it's not straightforward to write an expression which yields the global object. Hence, I placed the 'self' property on the global object to provide a convenient way of the getting a reference to it.

There are ways to get the global object, but they're not particularly pretty and I don't fully trust that kind of thing inside Qt's script environment anyway.

The second attribute specifies the signal binding. Specifically, the attribute name identifies the signal and is derived by pre-pending the string 'on' to the actual signal name. Hence, in this case, binding to 'theSignal' is specified using the attribute 'onTheSignal'. The value of the attribute is the JavaScript code to be executed when the signal fires. In our example it causes a simple little animation to occur.

Up to now, the only example I provided of using signals was the hsqml-morris demo application. It's not a great example of idiomatic QML because it uses a big chunk of JavaScript to work around some of the present limitations of HsQML's marshalling facilities (e.g. no lists/arrays). It makes no great attempt to be a "pure" QML application, so it just calls the signal's connect() method to attach it via JavaScript.

You could use the same approach with this test program by replacing the Connections element with the following code snippet:

        Component.onCompleted: {

The 'self' property is superfluous here because we can access the signal member on the global object directly. However, it's a slightly unfair comparison because the JavaScript code only covers connecting to the signal, whereas the Connections element also handles disconnections. When you're dynamically creating and destroying Components using things like the Repeater element, this is important to prevent overloading your signals with handlers that are never cleaned up.

The Connections element also allows the target attribute to be specified with a property or dynamic expression. If the value of the target expression changes at runtime then all the signal handlers will be disconnected and reconnected to the new object.

Addendum: Writing this example has made me think that HsQML relies too heavily on top-level data and instance declarations. I'd like to rectify that in the future by making QML classes first-class values on the Haskell side.
Categories: Offsite Blogs

Robin KAY: HsQML released: Now with Qt 5

Planet Haskell - Fri, 07/04/2014 - 3:35pm
I've just made a new major release of HsQML, my Haskell binding for the Qt Quick GUI framework. You can download it from Hackage in the usual manner.

This is a particularly exciting release because it's the first to have been ported over to use Qt 5. Previously, HsQML was developed against an older version of the Qt Quick technology which shipped as part of Qt 4.7 and 4.8. Support for Qt 5 has been a constant theme in the e-mails I get concerning HsQML for some time and so I'm pleased to finally deliver on that point.

There are also number of other improvements to the library which should allow more idiomatic QML code and hence reduce the need for helper JavaScript. Properties now support an associated notify signal which allows QML to automatically update in response to property changes rather than needing manual signal handlers. Also, lists and Maybe values can be marshalled between Haskell and QML natively, again reducing friction between the two environments.

The API has been redesigned slightly so that object classes and signal keys can be defined directly inside Haskell functions in addition to the older type-class based method. It's unclear yet if this style is wholly superior but, for smaller programs at least, it permits greater clarity and much less verbosity.

Finally, although still far from comprehensive, I've spent some time trying to improve the documentation on my web-site. It now provides some more substantial examples and goes into greater depth. The complete buildable source code for these examples is contained in the hsqml-demo-samples package. Also, the original Nine Men's Morris demo application is still available, but the package has been renamed to hsqml-demo-morris.

release- - 2014.05.04

* Ported to Qt 5 and Qt Quick 2
* Added type-free mechanism for defining classes.
* Added type-free mechanism for defining signal keys.
* Added property signals.
* Added marshallers for Bool, Maybe, and lists.
* Added less polymorphic aliases for def functions.
* Replaced Tagged with Proxy in public API.
* Removed marshallers for URI and String.
* New design for marshalling type-classes (again).
* Generalised facility for user-defined Marshal instances.
* Relaxed Cabal dependency constraint on 'QuickCheck'.
* Fixed GHCi on Windows with pre-7.8 GHC.
Categories: Offsite Blogs

Robin KAY: HsQML released

Planet Haskell - Fri, 07/04/2014 - 3:35pm
I've just released HsQML which, as usual, is available for download from Hackage. This release fixes several stability issues and also introduces a facility for defining properties with the CONST attribute.

If you use a property defined on one of your Haskell objects in a QML expression and that property doesn't have an associated signal, then Qt will print the following warning:

Expression depends on non-NOTIFYable properties

For mutable objects, the accurately informs us that QML has no way of knowing if the value of that property changes. However, when using Haskell, we often prefer to work with immutable values and there was previously no way of informing Qt that the value would never change. Previously, the only course of action was to specify a dummy signal or to use nullary methods instead of properties. You can now use the new defPropertyConst function instead of defPropertyRO to specify that an associated signal is unnecessary and suppress this warning.

As an aside, Christopher Reichert has just written a blog post about using HsQML which is well worth the read.

release- - 2014.06.11

* Added properties with constant annotation.
* Added runtime warning for users of the non-threaded RTS.
* Added non-TH version of Setup.hs.
* Relaxed Cabal dependency constraint on 'transformers'.
* Fixed premature garbage collection of QML objects.
* Fixed intermittent crash on exit when firing signals.
* Fixed crash when using Cmd-Q to exit on MacOS.
Categories: Offsite Blogs

HART 2014 - deadline extended

General haskell list - Fri, 07/04/2014 - 3:11pm
We extended the deadline until 12th July. ========================================= CALL FOR PAPERS Second Workshop on Haskell And Rewriting Techniques (HART 2014) To be held on September 5, co-located with ICFP 2014, the Haskell Symposium, etc., in Gothenburg. Haskell is an advanced purely-functional programming language. Pure functional programming is programming with equations, often defined by pattern-matching. Rewriting is the science of replacing equals by equals and thus a very powerful method for dealing with equations, often constructor-based. There are strong connections between Haskell (or generally, pure functional) programming and rewriting. The purpose of the HART workshop is to foster those connections. In addition to an invited talk by Oleg Kiselyov, we plan a half day of discussions, in an informal setting, on how Haskell (and related languages) and rewriting techniques and theories can cross-fert
Categories: Incoming News

How viable is using Haskell to make music? Should I be using Clojure + Overtone instead?

Haskell on Reddit - Fri, 07/04/2014 - 3:06pm


I'm interested in learning a functional programming language, and I'm also interested in making music using code (i.e. 'live coding').

Haskell is the functional language I really want to learn, but it doesn't seem to have a lively and active music making community, unlike Clojure with Overtone + Supercollider. So far I've stumbled across Tidal, which while incredibly cool, isn't designed to fulfil all your music making needs, unlike Overtone.

So, what are you thoughts? Should I try and get over the abundance of brackets + the JVM, and go with Clojure?


edit: I found this, it looks cool.

submitted by MrPopinjay
[link] [24 comments]
Categories: Incoming News

Request for code review: Dynamic programming

Haskell on Reddit - Fri, 07/04/2014 - 2:46pm

A recent working-paper A Comparison of Programming Languages in Economics compares the performance of different languages for a dynamic optimization problem arising in economics. The original code is on GitHub.

The authors have not considered any functional programming languages, though they promise to do so in a later paper. I have independently reimplemented their program in Haskell

My program, which uses REPA runs about 3 times slower than the authors' C++ program. I would greatly appreciate comments on my code, particularly about ways it can be made faster without sacrificing the quality of expression too much. I do not want to end up writing C++ in Haskell.

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

Ideal programming language for a new modern OS built from scratch?

Haskell on Reddit - Fri, 07/04/2014 - 4:35am

I know this is a Haskell forum, but Haskell community tends to be polyglot and fairly open-minded about right tool for right job. I've been thinking about fact that there are only two main OS architectures in personal computing: DOS/Windows line vs Unix line (MacOS/iOS, Linux, Android). What if someone (finally) decided to build a completely new OS from scratch without re-hashing Unix yet again and designing it to meet the needs of modern devices, networks, services, etc. What would be the programming language of choice for a low level 'modern' operating system if restricted to known languages (old or recent) as opposed to also inventing another hypothetical 'ideal' language?

Here are the choices:

  1. Assembly language
  2. C
  3. Lisp variant
  4. Java
  5. Erlang
  6. Golang
  7. Haskell
  8. Javascript (gasp!)
  9. ML variant
  10. Scala
  11. Rust
  12. Logic programming (Prolog, Mercury)
  13. Other (specify)
submitted by RaymondWies
[link] [61 comments]
Categories: Incoming News

Type-level Nat to Integer

haskell-cafe - Thu, 07/03/2014 - 10:03pm
Hi all, I'm trying to change type-level Nat to Integer as following: {-# LANGUAGE DataKinds, KindSignatures, GADTs, PolyKinds #-} data Nat = Z | S Nat class NatToInt n where natToInt :: n -> Int instance NatToInt Z where natToInt _ = 0 instance NatToInt (S n) where natToInt = 1 + natToInt (undefined :: n) I understand why it fails (Z and S have not the right kind). How to specify that NatToInt is Nat-specific? Moreover, if you have any advanced explanations/links which could give me a deeper understanding on what going on, I'll take them. Thanks in advance for your help. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Final Call for Papers: OCL 2014 Submissions Due in OneWeek

General haskell list - Thu, 07/03/2014 - 4:15pm
(Apologies for duplicates) CALL FOR PAPERS 14th International Workshop on OCL and Textual Modeling Applications and Case Studies (OCL 2014) Co-located with ACM/IEEE 17th International Conference on Model Driven Engineering Languages and Systems (MODELS 2014) September 28-30 (tbc), 2014, VALENCIA, SPAIN Modeling started out with UML and its precursors as a graphical notation. Such visual representations enable direct intuitive capturing of reality, but some of their features are difficult to formalize and lack the level of precision required to create complete and unambiguous specifications. Limitations of the graphical notations encouraged the development of text-based modeling languages that either integrate with or replace graphical notations for modeling. Typical examples of such languages are OCL, textual MOF, Epsilon, and Alloy. Textual modeling languages have thei
Categories: Incoming News

Final Call for Papers: OCL 2014 Submissions Due inOne Week

haskell-cafe - Thu, 07/03/2014 - 4:15pm
(Apologies for duplicates) CALL FOR PAPERS 14th International Workshop on OCL and Textual Modeling Applications and Case Studies (OCL 2014) Co-located with ACM/IEEE 17th International Conference on Model Driven Engineering Languages and Systems (MODELS 2014) September 28-30 (tbc), 2014, VALENCIA, SPAIN Modeling started out with UML and its precursors as a graphical notation. Such visual representations enable direct intuitive capturing of reality, but some of their features are difficult to formalize and lack the level of precision required to create complete and unambiguous specifications. Limitations of the graphical notations encouraged the development of text-based modeling languages that either integrate with or replace graphical notations for modeling. Typical examples of such languages are OCL, textual MOF, Epsilon, and Alloy. Textual modeling languages have thei
Categories: Offsite Discussion

Restarting doc build on hackage

haskell-cafe - Thu, 07/03/2014 - 2:55pm
Hi cafe, Does anyone know if there is a way to restart a documentation build on hackage? We have a package where the documentation failed to build due to a dependency lacking upper bounds. That has recently been fixed (using the new in-place cabal file editing feature), and we'd like to get documentation for our package now. Is there any way to do this (apart from uploading a new version without changes)? Erik
Categories: Offsite Discussion

Writing a plugin to save xmonad state?

Haskell on Reddit - Thu, 07/03/2014 - 2:33pm

I've been using the xmonad tiling window manager for a while now, and picked up a bit of Haskell along the way so I could make sense of configuring it. I'm mainly a Python guy, and I enjoyed doing a bit of Clojure not too long ago - I really liked it, but pure functional languages like Haskell are new to me.

I soon came to need one feature that xmonad lacks - namely, being able to save the current state of a workspace, complete with any modifications to the layout state such as resizing and reordering windows. This StackOverflow answer comes pretty close: xmonad already stores and then reloads all of its state when you restart it. I would like to implement this in order to learn some actual Haskell; however, I'm a complete newb at Haskell and I find myself at a complete loss.

I'm thinking of starting out by writing something like a LayoutModifier which responds to a message and writes the underlying layout's state to a file... only I don't understand file IO in Haskell and can't figure out whether the layout state would be in the available scope. Actually, can a LayoutModifier even take a Choice of layouts (which the ||| layout combinator seems to be returning)? Do you nice folks happen to have any pointers?

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

Proposal: New mailing lists -- haskell-jobs &haskell-academia

haskell-cafe - Thu, 07/03/2014 - 2:33pm
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 The proposal is simply as follows. 1. Make a list, haskell-jobs. This would be primarily for job postings and looking-for-job posts. A secondary purpose is discussing jobs. E.g. "Anyone know any jobs in the Foo area?", and meta-discussions like "How well does Haskell jobs pay in your experience?". 2. Make a list, haskell-academia. This would be primarily for studentship postings and call for papers. A secondary purpose is discussing academia. E.g. "Anyone know any unis that use Haskell extensively in the Foo area?", and meta-discussions like "How well is Haskell taught at unis in your experience?" The motivation for this is twofold. 1. We get a lot of job postings and studentship postings. Many of these will be ignored by readers, up until they suddenly find themselves looking for a job or studentship. It would be useful if they could then easily filter their email on lists -- or go to the online archives for that specific list. The latter is a big Win, b
Categories: Offsite Discussion

Haste-perch: for dynamic html

Haskell on Reddit - Thu, 07/03/2014 - 8:15am
Categories: Incoming News