News aggregator

Six Points About Type Safety

Haskell on Reddit - Fri, 08/08/2014 - 8:38am
Categories: Incoming News

Visualising Haskell function execution

haskell-cafe - Fri, 08/08/2014 - 6:30am
Hey all, Last weekend my friend Steve and I did a small project for visualising Haskell function execution in the browser. It's meant to be used in education, and uses a tiny custom parser. I figured it could be of interest for anyone here learning or teaching Haskell: To see it in action, scroll a bit down to the red bordered box, and click on "map", and then keep clicking on each new line. I hope it can be useful to someone. Cheers, JP _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

How to improve the zipwith's performance

haskell-cafe - Fri, 08/08/2014 - 4:24am
Dear All I write a code for Clustering with Data.Clustering.Hierarchical, but it's slow. I use the profiling and change some code, but I don't know why zipwith take so many time? (even I change list to vector) My code is as blow, Any one kindly give me some advices. ====================== main = do .... let cluster = dendrogram SingleLinkage vectorList getVectorDistance .... getExp2 v1 v2 = d*d where d = v1 - v2 getExp v1 v2 | v1 == v2 = 0 | otherwise = getExp2 v1 v2 tfoldl d = DV.foldl1' (+) d changeDataType:: Int -> Double changeDataType d = fromIntegral d getVectorDistance::(a,DV.Vector Int)->(a, DV.Vector Int )->Double getVectorDistance v1 v2 = fromIntegral $ tfoldl dat where l1 = snd v1 l2 = snd v2 dat = DV.zipWith getExp l1 l2 ======================================= build with ghc -prof -fprof-auto -rtsopts -O2 log_cluster.hs run with log_cluster.exe +RTS -p profiling result is log_cluster.exe +RTS -p -RTS total time =
Categories: Offsite Discussion

Bryan O'Sullivan: criterion 1.0

Planet Haskell - Fri, 08/08/2014 - 4:02am
<html xmlns=""> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> <meta content="text/css" http-equiv="Content-Style-Type"/> <meta content="pandoc" name="generator"/> <style type="text/css">code{white-space: pre;}</style> </head> <body>

Almost five years after I initially released criterion, I'm delighted to announce a major release with a large number of appealing new features.

As always, you can install the latest goodness using cabal install criterion, or fetch the source from github.

Please let me know if you find criterion useful!

New documentation

I built both a home page and a thorough tutorial for criterion. I've also extended the inline documentation and added a number of new examples.

All of the documentation lives in the github repo, so if you'd like to see something improved, please send a bug report or pull request.

New execution engine

Criterion's model of execution has evolved, becoming vastly more reliable and accurate. It can now measure events that take just a few hundred picoseconds.

benchmarking return () time 512.9 ps (512.8 ps .. 513.1 ps)

While almost all of the core types have changed, criterion should remain API-compatible with the vast majority of your benchmarking code.

New metrics

In addition to wall-clock time, criterion can now measure and regress on the following metrics:

  • CPU time
  • CPU cycles
  • bytes allocated
  • number of garbage collections
  • number of bytes copied during GC
  • wall-clock time spent in mutator threads
  • CPU time spent running mutator threads
  • wall-clock time spent doing GC
  • CPU time spent doing GC
Linear regression

Criterion now supports linear regression of a number of metrics.

Here's a regression conducted using --regress cycles:iters:

cycles: 1.000 R² (1.000 R² .. 1.000 R²) iters 47.718 (47.657 .. 47.805)

The first line of the output is the R² goodness-of-fit measure for this regression, and the second is the number of CPU cycles (measured using the rdtsc instruction) to execute the operation in question (integer division).

This next regression uses --regress allocated:iters to measure the number of bytes allocated while constructing an IntMap of 40,000 values.

allocated: 1.000 R² (1.000 R² .. 1.000 R²) iters 4.382e7 (4.379e7 .. 4.384e7)

(That's a little under 42 megabytes.)

New outputs

While its support for active HTML has improved, criterion can also now output JSON and JUnit XML files.

New internals

Criterion has received its first spring cleaning, and is much easier to understand as a result.


I was inspired into some of this work by the efforts of the authors of the OCaml Core_bench package.

</body> </html>
Categories: Offsite Blogs

Can I safely delete the older files in my .cabal folder?

Haskell on Reddit - Fri, 08/08/2014 - 12:58am

My current .cabal folder looks like



--------------- 00-index.tar


------- x86_64-osx-ghc-7.8.2





------- setup-Configure-Cabal-

------- setup-Simple-Cabal-

Can I delete all the files I've bolded?

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

How do parametricity and type classes interact?

Haskell on Reddit - Thu, 08/07/2014 - 11:43pm

I've heard responses that they do not interact since type classes are ad-hoc and parametricity requires parametric polymorphism as the name indicates.

But in Wadler's paper Theorems for Free! he gives examples of some theorems (given a : A → A′ and b : B → B′):

sort : ∀X. (X → X → Bool) → [X] → [X] if for all x, y ∈ A, (x < y) = (a x <′ a y) then map a ∘ sort (<) = sort (<′) ∘ map a fold : ∀X. ∀Y. (X → Y → Y) → Y → [X] → Y if for all x ∈ A, y ∈ B, b (x ⊕ y) = (a x) ⊛ (b y) and b u = u′ then b ∘ fold (⊕) u = fold (⊛) u′ ∘ map a

sort corresponds to Haskell's Data.List.sortBy but you could also view both of those parametrically polymorphic functions as ad-hoc functions whose type constraints (Ord and Foldable) have been reified into arguments. So is it valid to view ad-hoc polymorphic functions such as \x -> x == x with type Eq a => a -> Bool as having the following parametric type (a -> a -> Bool) -> a -> Bool (ignoring (/=))?

submitted by haskellthrowaway
[link] [11 comments]
Categories: Incoming News

Looking for name of a concept (relating to parametricity)

Haskell on Reddit - Thu, 08/07/2014 - 11:27pm

Given a function of the following type:

f :: [a] -> [a]

Due to parametricity, the only information f has to make choices is the length of its input list since that is the only “element-independent “information content” of a list”.

Is there a name for this information, the information content you can retrieve from a data type when one or more of its types are parametrically polymorphic.

submitted by haskellthrowaway
[link] [16 comments]
Categories: Incoming News

How does Accelerate performance compare to handwritten OpenCL/CUDA?

Haskell on Reddit - Thu, 08/07/2014 - 10:57pm

I guess it would be much slower, or else why would anyone use CUDA. But has anyone benchmarked it? How does it compare?

submitted by SrPeixinho
[link] [7 comments]
Categories: Incoming News

[ANN] rtorrent-state

haskell-cafe - Thu, 08/07/2014 - 8:07pm
Hi, rtorrent-state is a library that allows working with rtorrent state files (SOMEHASH.torrent.rtorrent) placed in your session directory. If you're an rtorrent user and ever had to manually muck around with those files, you should be able to use this library to make your life easier. For example, you can stop all torrents in your session directory with just: “overFilesIn "rtorrent/session/dir" stopTorrent” The way it works is by parsing the session files, modifying the resulting data type and serialising it back into the file. I did not do optimisation but I had no problem with test sample of 100,000 files. I need to add IOException handling and maybe extra utility functions but otherwise I consider the library finished. Thanks
Categories: Offsite Discussion

Haskell is a medium-sized dog

Haskell on Reddit - Thu, 08/07/2014 - 7:18pm
Categories: Incoming News

Performance of StateT and best practices fordebugging

haskell-cafe - Thu, 08/07/2014 - 6:57pm
Hello, I was looking at cleaning up my refactoring a core loop of template rendering to go from a loop with many parameters loop :: RenderConfig -> BlockMap -> InputBucket m -> Builder -> [Pieces] -> ExceptT StrapError m Builder to a looped state monad transformer loop :: [Pieces] -> RenderT m Builder newtype RenderT m a = RenderT { runRenderT :: ExceptT StrapError (StateT (RenderState m) m) a } deriving ( Functor, Applicative, Monad, MonadIO ) data RenderState m = RenderState { position :: SourcePos , renderConfig :: RenderConfig , blocks :: BlockMap , bucket :: InputBucket m } however, there is a big slow down (about 6-10x) using a StateT. I think it might have something to do with laziness but I am not exactly sure of where to begin in tracking it down. Swapping out the Lazy State to a Strict State helps a little (only a 5x slow down) You can find some of the processing code here:
Categories: Offsite Discussion

parsec: problem combining lookAhead with many1 (bug?)

haskell-cafe - Thu, 08/07/2014 - 3:25pm
Suppose that we have the following parser: p = lookAhead (char 'a') >> char 'b' If we use it like so parse p "" "a" we get the following error: Left (line 1, column 1): unexpected "a" expecting "b" What happened is that char 'a' succeeded by consuming the 'a' from the input and then lookAhead rewinded the input stream (as it does on success). Then, char 'b' tries to parse (again) the first character of the input and fails. Everything works as expected. Now let's slightly modify our parser: p' = lookAhead (many1 $ char 'a') >> char 'b' I've only added a many1. I was expecting this parser to give the same error as the previous one: many1 $ char 'a' will succeed consuming one 'a' and then lookAhead will rewind the input (as it does on success). Thus when we call char 'b' we are going to be in the beginning of the input again. Well, that doesn't happen: Left (line 1, column 2): unexpected end of input expecting "b" As you can see, lookAhead did not rewind the input as it was supposed to.
Categories: Offsite Discussion

Free monad based EDSL for writing LLVM programs.

haskell-cafe - Thu, 08/07/2014 - 3:16pm
Hello. I'm new with Haskell and FP, so i wanted someone to give comments on the package i've made [1]. It's, actually, my first attempt to create something more or less real, so any feedback would be welcome. I've used Free monad to create EDSL that allows writing LLVM IR code. Afterwards it could be converted into pure AST structure provided by llvm-general-pure[2] package. Currently, it supports almost every instruction, but i haven't yet come up with sensible defaults for them. Another thing that bugs me is the ability to transform the code in syb way. I want take a user-supplied function that would pattern-match instruction and produce another code block and apply this function everywhere in the code, but still can't get my head around it. I've come up with extF function, that unlike extM, would resort to wrap instead of return, but that's all i've managed to do. Thanks in advance. [1] [2] _______
Categories: Offsite Discussion