News aggregator

Profiling with an interpreter

haskell-cafe - Sat, 10/18/2014 - 7:57pm
Hi, I'm trying to profile my game (Nomyx) but I get: "You can't call hscCompileCoreExpr in a profiled compiler". I figured out it's because I'm embbeding an intrepreter. Is there a way to avoid that and profile anyway? Maybe ignoring the calls to the interpreter or something... Cheers Corentin _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

ghci uses readline

Haskell on Reddit - Sat, 10/18/2014 - 11:30am

Readline is the standard GNU library to get user input for interactive programs. It's what enables the up/down arrows to search through history. But it also enables a LOT more.

My personal most used command is the ctrl-r command to search through your history. Here's a list of more common shortcuts. The readline documentation contains full details including how to add your own shortcuts. For die-hard vim users, you can even force readline to accept vim keybingings!

submitted by PokerPirate
[link] [26 comments]
Categories: Incoming News

Making GHCi awesomer?

Haskell on Reddit - Sat, 10/18/2014 - 9:59am
Categories: Incoming News

Using phantom types for specifying algorithmic behaviour?

Haskell on Reddit - Fri, 10/17/2014 - 10:42pm

I'm wondering if there has been anything similar done, and if you have any specific thoughts about using such a pattern, and the implicit reliance on using typeclasses to encode "behaviour".

Code sample to illustrate what I'm thinking of

{-# Language EmptyDataDecls, FlexibleInstances #-} module Algorithmic where import Data.Foldable import Data.Monoid data LeftFold data RightFold data Tree b a = Empty | Leaf a | Node (Tree b a) a (Tree b a) deriving Show instance Functor (Tree b) where fmap f Empty = Empty fmap f (Leaf a) = Leaf (f a) fmap f (Node l c r) = Node (fmap f l) (f c) (fmap f r) instance Foldable (Tree LeftFold) where foldMap f Empty = mempty foldMap f (Leaf x) = f x foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r instance Foldable (Tree RightFold) where foldMap f Empty = mempty foldMap f (Leaf x) = f x foldMap f (Node l k r) = foldMap f r `mappend` f k `mappend` foldMap f l sample1 :: Tree b Int sample1 = Node (Node (Leaf 1) 2 (Leaf 3)) 4 (Node (Leaf 5) 6 Empty) test1 = Data.Foldable.foldr (:) [] (sample1 :: Tree LeftFold Int) test2 = Data.Foldable.foldr (:) [] (sample1 :: Tree RightFold Int) submitted by alt_account10
[link] [3 comments]
Categories: Incoming News

beginnners book

haskell-cafe - Fri, 10/17/2014 - 7:14pm
Hello, What is a good book to learn Haskell with a lot of exercises so I can check if I understand everything right ? Roelof
Categories: Offsite Discussion

A neat trick for GHCi

Haskell on Reddit - Fri, 10/17/2014 - 6:16pm
Categories: Incoming News

2^770000 triggers Bus Error?

haskell-cafe - Fri, 10/17/2014 - 4:46pm
Running ghci under OSX I am seeing the following behavior: Prelude> 2^750000 {... lots of digits...} Prelude> 2^760000 Segmentation Fault: 11 Prelude> 2^770000 Bus Error: 10 and I'm curious why this happens. More details: $ ghci --version The Glorious Glasgow Haskell Compilation System, version 7.8.3 I'm using the 64-bit version of the Haskell Platform (x86_64-darwin-7.8.3). _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Erik de Castro Lopo: Haskell : A neat trick for GHCi

Planet Haskell - Fri, 10/17/2014 - 4:16pm

Just found a really nice little hack that makes working in the GHC interactive REPL a little easier and more convenient. First of all, I added the following line to my ~/.ghci file.


All that line does is define a GHC_INTERACTIVE pre-processor symbol.

Then in a file that I want to load into the REPL, I need to add this to the top of the file:


and then in the file I can do things like:

#ifdef GHC_INTERACTIVE import Data.Aeson.Encode.Pretty prettyPrint :: Value -> IO () prettyPrint = LBS.putStrLn . encodePretty #endif

In this particular case, I'm working with some relatively large chunks of JSON and its useful to be able to pretty print them when I'm the REPL, but I have no need for that function when I compile that module into my project.

Categories: Offsite Blogs

Neil Mitchell: Fixing Haddock docs on Hackage

Planet Haskell - Fri, 10/17/2014 - 2:49pm

Summary: A few weeks ago Hackage stopped generating docs. I have a script that generates the docs, and also fixes some Haddock bugs.

Update: The Haddock documentation generators are running once again, but may be somewhat behind for a little while. A few weeks ago Hackage stopped generating documentation, so if you look at recently uploaded pages they tend to either lack docs, or have very alert maintainers who did a manual upload. I've packaged up my solution, which also fixes some pretty annoying Haddock bugs. Given that I can now get docs faster and better with my script, I'll probably keep using it even after Haddock on Hackage gets restarted.

How to use it

  • You are likely to get better results if you always install the packages you use with documentation.
  • Ensure you have tar, curl, cp and cabal on your $PATH.
  • cabal update && cabal install neil
  • Make a release, don't touch any other code, then make sure you are in the project directory.
  • neil docs --username=YourHackageUsername
  • Type in your Hackage password at the prompt.

And like that, your docs are online. To see an example of something that was generated with this process, look at Shake.

What I fixed

I automated the process using scripts originally taken from the lens library, supplemented with suggestions from Reddit. I then do a number of manual fixups.

  • Haddock now makes cross-module links where it doesn't know what the target is default to types. Concretely, if I write 'Development.Shake.need' in Haddock it generates a link to #t:need, which doesn't exist, when it should be #v:need - I fix that.
  • Update: fixed in Haddock 1.14 or above, as per this ticket.
  • On Windows, if you use CPP and multiline bird-tick (>) Haddock blocks you get a blank line between each line. I fix that.
  • If you follow some of the simpler scripts links outside your package won't work (or at least, didn't for me). I fix that.

The neil tool

The neil tool is my personal set of handy Haskell scripts. I make all my releases with it (neil sdist), and do lots of checks that my packages conform to my rules (neil check). I also use it for driving my Travis instances. It's in fairly regular flux. Until now, I've always kept it in Darcs/Git and never released it - it's personal stuff tuned to how I work.

You might also notice that neil provides a library. Don't use that, I intend to delete it in a few weeks. Update: library removed.

Categories: Offsite Blogs

visual editing of haskell code for computer music

Haskell on Reddit - Fri, 10/17/2014 - 2:45pm

Hi! I recently stumbled over this article: Visual Haskell: A First Attempt (H. John Reekie, 1994)

It proposes a graphical language (called "visual haskell") isomorphic to a subset of haskell. This graphical language is inspired by well known dataflow languages used as tools for computer music (e.g. puredata). It also points out some analogies between the functional programming paradigma and the control flow paradigma.

I find the idea extremlely appealing - I wonder if there would be a way to create a tool that allows for graphical editing of haskell programs by exploiting the analogies between the functional programming paradigm and dataflow graph diagrams. Would such a tool be an adequate solution to create computer music (or more general: for modeling signal processing graphs), like puredata?

so I started to research about:

  • digital (audio) signal processing using haskell
  • existing tools for making computer music using haskell

3 Names seem to be relevant: H. John Reekie, Henning Thielemann, Paul Hudak.

These are the articles I found so far: found at : found at found at : * [Haskell School Of Music - From Signals to Symphonies (Paul Hudak, ver. 2.6 vom Januar 2014)]( These are the existing tools/libraries to create computer music using haskell I found so far:
  • Euterpea:

    • successor of Haskore and HasSound
    • computer music library proposed by the paper "Haskell School Of Music - From Signals to Symphonies" (Paul Hudak)
  • Synthesizer

    • library for digital signal processing as proposed by the paper "Compiling Signal Processing Code embedded in Haskell via LLVM" (Henning Thielemann)
  • dsp

    • another library for signal processing by Henning Thielemann?

Suggestions about articles to read, persons to get in touch with, tools to take a look on would be greatly appreciated.

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