News aggregator

ANN: clustering-0.1.0

haskell-cafe - Mon, 03/02/2015 - 7:37am
https://hackage.haskell.org/package/clustering This package provides optimal algorithms (O(N^2)) for hierarchical clustering, including single linkage, complete linkage, average linkage, weighted linkage, and Ward's method. Benchmarks of average linkage can be found here: https://github.com/kaizhang/clustering. I hope this would be useful in general. Motivation of this work: I found the "hierarchical-clustering" library cannot handle large input (>10^4) due to its suboptimal algorithms. Best, Kai _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Why does GHC immediately think of TemplateHaskell?

Haskell on Reddit - 3 hours 58 min ago
Prelude> let f a b = undefined Prelude> 1 `f` $ 2 <interactive>:98:7: parse error on input ‘$’ Perhaps you intended to use TemplateHaskell submitted by alt_account10
[link] [4 comments]
Categories: Incoming News

What to you think about the Fsharp piping operators in prelude.hs

Haskell on Reddit - 4 hours 7 min ago

What do you think about the F# pipeline operators in prelude·hs. I think they are very convenient and readable to perform sequential operations. F# has only the |>, but I defined the |>> to represent map and |?> to represent filter.

Example:

-- Fsharp Operators (|>) x f = f x (|>>) x f = map f x (?>>) x f = filter f x > let (|>) x f = f x > > let (|>>) x f = map f x > let (?>>) x f = filter f x > take 3 (reverse (filter even [1..10])) [10,8,6] > [1..10] |> filter even |> reverse |> take 3 [10,8,6] > > [1..10] |>> (^2) |>> (/10) |>> (+100) [100.1,100.4,100.9,101.6,102.5,103.6,104.9,106.4,108.1,110.0] > > [1..10] ?>> even [2,4,6,8,10] > > [1..10] ?>> even |>> (+1) [3,5,7,9,11] > >

Other example:

parseCSVcont content = (header, matrix) where header = content |> splitLines |>> splitComma |> head matrix = content |> splitLines |>> splitComma |> tail |>> map readDouble submitted by eniacsparc2xyz
[link] [9 comments]
Categories: Incoming News

Created a simple (incomplete) JSON Parser using Applicatives

Haskell on Reddit - 4 hours 28 min ago

https://github.com/kevinmeredith/json_parser

If you could please take a look at Model.hs and JsonParser.hs - for my own learning.

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

Douglas M. Auclair (geophf): February 2015 1HaskellADay Problems and Solutions

Planet Haskell - 5 hours 12 min ago

February 2015
  • February 27th, 2015: Let's put all our primes in a circle, shall we? http://lpaste.net/121154 Ah, how cute! Today's #haskell problem suggested by @jamestanton @bretthall defines a solution, with some analysis, at http://lpaste.net/121292
  • February 26th, 2015: Okay, check this! Today's #haskell problem is as easy as 1, 2, 3! http://lpaste.net/121250 An easy as π solution is posted at http://lpaste.net/121273 ... mmm! π! But is it apple π or ... raspberry π? #couldntresist
  • February 25th, 2015: I'd like moccha sprinkles on my double capicua, please. http://lpaste.net/121153 No. Wait. Today's #haskell problem suggested by a tweet from @OnThisDayinMath
  • February 24th, 2015: Not satisfied with a simple square-from-square problem @BenVitale takes it up a notch and asks us to cube dat square! http://lpaste.net/121060 We have one solution out of 20k squares posted at http://lpaste.net/121150 : [(39204,39304)]
  • February 23rd, 2015: I hereby christen this week a fun-with-numb3rs week, and start us off by learning that 'easierest' is a word, http://lpaste.net/121034, just like 'ginormous.' And the winner is...no, wait! Ladies and gentlemen, we have MULTIPLE winners! http://lpaste.net/121052 Good thing the solution isn't the Lotto No, wait. The problem statement wasn't read carefully by the solution-poster. I blame that wicked, wicked @geophf! Bad geophf! Bad! ;)
  • February 20th, 2015: It's a #Borderlands2 Truxican Standoff for you to resolve in today's #haskell problem http://lpaste.net/120819 The solution is simple really: just a projection into a monad category in order to do some monoidal deduction is all! http://lpaste.net/120916
  • February 19th, 2015: For today's #haskell problem we learn that 'AEKL' is a word in English http://lpaste.net/120775 (no, it's not, actually) A megalokaryocyte-solution is posted at http://lpaste.net/120816 (now, that's a common word ... NOT! ;)
  • February 18th, 2015: Instead of doing today's #haskell problem, let's go ice skating. No, let's do BOTH! http://lpaste.net/120722 Okay, a loquacious solution? garrulous? Yes. Once one cuts through all the attempts, it's a simple solution, too: http://lpaste.net/120873 ... and updated the solution with the monoidal guarantee-by-implication that the result is unique (instead of just hoping it is) #coercivelogic
  • February 17th, 2015: For today's #haskell problem we are asked to 'fix' our monetary problems (or the library, at least) http://lpaste.net/120630 Made Data.Monetary.USD a Fractional instance http://lpaste.net/109653 and eliminated floating point creep #haskell #money #precision 
  • February 16th, 2015: Getting a jump-start on the day with two really, really hard math problems for today's #haskell problem http://lpaste.net/120560 A solution in which we learn a baseball costs a nickel ... IN WHICH CENTURY? http://lpaste.net/120560
  • February 13th, 2015: Today's SCARY #haskell problem comes by way of @OnThisDayinMath http://lpaste.net/120422 Tonight's late-night movie, Friday the 13th, part III http://lpaste.net/120466 as the solution to today's #haskell problem.
  • February 12th, 2015: Gurer ner gvzrf jura ... yeah. That. http://lpaste.net/120388 Today's #haskell problem, thanks to @KenKenPuzzle The solution shows us that it's INTENSE unscrambling words http://lpaste.net/120407
  • February 11th, 2015: Change adds up quickly in today's #haskell problem http://lpaste.net/120320 So, but ... does that mean programming is like ... maths? Nah! http://lpaste.net/120333 A solution to today's #haskell problem
  • February 10th, 2015: The price of a letter (or of all letters of the alphabet) http://lpaste.net/120236 is the question for today's haskell problem. In the solution we learn the geophfmeister is down-low on the B.I.G. 323, yo! http://lpaste.net/120294
  • February 9th, 2015: 'Oh, no!' ... just another Manic Monday ... AND today's #haskell problem http://lpaste.net/120196 Oh, noes! Mr. Bill!http://lpaste.net/120208 A solution to the oh, no!-problem.
  • February 6th, 2015: It's Friday! Friday! Hava #haskell problem on Friday! Fun-fun-fun! Lookin' forward to the weekend! http://lpaste.net/120087 Groovin' to aRebecca Black solution at http://lpaste.net/120095
  • February 5th, 2015: Triangles and Squares as numbers http://lpaste.net/120037 for today's Haskell problem. A Triangulated-squares solution is provided by @bretthall at http://lpaste.net/120040
  • February 4th, 2015: Three birds in the hand is better than today's #haskell problem http://lpaste.net/119926 an ornithologist's delight inspired by @KenKenPuzzle. The solution, using MultiMaps, PartitionedSets, and Arrows is (@geophf-obviously) "WOOT! WOOT! WOOT!" http://lpaste.net/120065
  • February 3rd, 2015: We entertain a foolish attempt at a #haskell problem, and then we get serious with six sewing seamstresses http://lpaste.net/119867 A silly seamstress solution is posted at http://lpaste.net/119888 
  • February 2nd, 2015: Today's #haskell exercise is all about the #SuperBowl! (No, it's not, but that makes for good copy), or 110, 210, ... http://lpaste.net/119791 The moral (and solution) to this story is: Don't eat cheerios seasoned with basil. http://lpaste.net/119823 Or something like that. Inspired by @bretthall solution, I expanded to include last-3-of-4 digits for solutions to bases 4,5,6 @jamestanton
Categories: Offsite Blogs

Manuel M T Chakravarty: Type-safe Runtime Code Generation with LLVM

Planet Haskell - 5 hours 14 min ago

The embedded high-performance language Accelerate has got a new backend based on LLVM, which generates code for multicore GPUs and CPUs. In a new paper, we describe this code generator, which is —as far as we are aware— the first practical code generator that is fully type preserving from the source language down to generating low-level LLVM intermediate code (in SSA form). In addition to its novel safety features, the new backend generates vectorised SIMD code for x86_64 CPUs (using LLVM’s vectorisation support) and achieves competitive performance on a range of preliminary benchmarks.

Categories: Offsite Blogs

ANNOUNCE postgresql-query and postgresql-config

haskell-cafe - 10 hours 48 min ago
Hi guys! Here is yet another some-level library to work with PostgreSQL DB. http://hackage.haskell.org/package/postgresql-query This library uses `postgresql-query` and is a list of helpers/workarounds to generate complex queries more safely and parse result. What it contains: 1. interplating quasiquote `sqlExp` which uses instances of `ToField` typeclass to paste values inside query. It looks like this: let val = "'hello'" :: Text q = [sqlExp|SELECT field1 FROM tbl WHERE field2 = #{val}|] where `val` is an arbitrary Haskell expression which type has instance of `ToField` Resulting query will be like: "SELECT field1 FROM tbl WHERE field2 = '''hello'''" Yes, proper string escaping is performed authomatically like using this '?'-like queries with parameters. Resulting type of quasiquote is `SqlBuilder` which uses bytestring builders inside and can be concatenated efficiently. There is also posibility to paste one query inside another like: let q2 = [sqlExp|
Categories: Offsite Discussion

Coherent type classes

Haskell on Reddit - 11 hours 48 min ago

I'm trying to understand the trade off between coherent type class instances with newtypes and possible alternatives.

Assume a language where type class instances are typed and passed explicitly.

typeclass Monoid<A> { op(A, A) : A; id : A; } reduce<A, M : Monoid<A>>(xs : [A], m : M) : A = foldr(m.op, m.zero, xs); singleton IntSumMonoid : Monoid<Int> { op = (+); id = 0; } singleton IntProductMonoid : Monoid<Int> { op = (*); id = 1; }

I believe this rules out type inference. Are there other drawbacks?

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

Language.JsonGrammar

Haskell on Reddit - 14 hours 54 min ago
Categories: Incoming News

Dimitri Sabadie: al 0.1.0.2 – documentation and default paths

Planet Haskell - 15 hours 15 min ago
al patch

This is a very short article to make you notice that al received two important changes:

  • I uploaded documentation (hourra!) ;
  • OpenAL paths will default to default installation on Windows systems.

I tested the latter with a Windows 64b:

cabal update
cabal install al

That’s all. You should try it out as well. If you have errors about OpenAL libraries and/or header files, check whether OpenAL is correctly installed. If the error comes up again, proceed as I said here.

Also, I take people on linux feedback about installs ;).

Categories: Offsite Blogs

ghci and dynamically linking to Objective-C objectson Mac OS X

haskell-cafe - 17 hours 9 min ago
Hi all, I fear I might be unaware of something I should be. Say I have a file objc_util.m with the following contents: #include <Foundation/Foundation.h> void ns_log(const char *s) { NSString *str = [NSString stringWithUTF8String:s]; NSLog(< at >"%< at >", str); } I also have a file Main.hs with contents: {-# LANGUAGE ForeignFunctionInterface #-} module Main where import Foreign.C.Types import Foreign.C.String foreign import ccall "ns_log" cNSLog :: CString -> IO () nsLog s = withCString s cNSLog I compile objc_util.m with: gcc -c objc_util.m And then I try to open it up in GHCi. ghci objc_util.o Main.hs -framework Foundation I add the flag '-frame Foundation' in the hopes that symbols in objc_util.o will get resolved dynamically. However I get: GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linki
Categories: Offsite Discussion

how to get the first element which satisfies some conditions from a list?

Haskell on Reddit - 17 hours 37 min ago

I'm encountering a problem that I want to find out the first element which satisfies some conditions from a list.

for example, give a list of Char : l = ['a','b','c','d'] and a function trans:

trans :: Char -> Int trans 'a' = 2 trans 'b' = 3 trans 'c' = 1 trans 'd' = 0

What I want to do is to build a function which get the char c, whose (tans c) value is the maximum of the list l.

I tried to write a function like this:

find list = list !! (head $ findIndices (\x -> trans x == maximum (map tans list)) list)

It looks like really complex. So is there and build-in function or better solution?

Thanks.

submitted by Arcovitcher
[link] [18 comments]
Categories: Incoming News

Library_submissions and Call for Maintainers

libraries list - 18 hours 39 min ago
We've had a lot of feedback over the last few months trying to get clarification on the role of the core libraries committee, and on the libraries< at > process in general. In particular, Simon Peyton Jones asked us in his own rather inimitable manner to make sure that we sat down and started documenting things. After all, we've now been at this for almost a year and a half, and have started to figure out what is working and what isn't. In response to that feedback, we've recently taken the time to go through and update the Library_submissions <https://wiki.haskell.org/Library_submissions> page rather extensively to better describe and refine the libraries< at > process and better define the role of the core libraries committee. Changes of note: * Up until now we've been using the rather ad hoc definition of "core libraries" as libraries that come with the Haskell Platform and which are subject to the libraries< at > proposal process. We've recently taken it upon ourselves to clarify this further. To that end we've upda
Categories: Offsite Discussion

A Question about IO monad

haskell-cafe - Sun, 03/01/2015 - 1:44am
Hi i have a question about IO monad. Sometimes IO do something and return something, i wonder if the return type, for example is IO Int means it will return an int, could i purely fetch the int? but i fail, i cannot construct a function, i use do notation but i found i must use something to pass the int to another monad. But i could write a function has the type of Maybe a -> a and it is easily. Maybe monad and IO monad both instance monad but why i can’t do that? Zongzhe Yuan This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may st
Categories: Offsite Discussion

A Question about IO

haskell-cafe - Sun, 03/01/2015 - 1:40am
Hi i have a question about IO monad. Sometimes IO do something and return something, i wonder if the return type, for example is IO Int means it will return an int, could i purely fetch the int? but i fail, i cannot construct a function, i use do notation but i found i must use something to pass the int to another monad. But i could write a function has the type of Maybe a -> a and it is easily. Maybe monad and IO monad both instance monad but why i can’t do that? Zongzhe Yuan This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may st
Categories: Offsite Discussion

ANN: diagrams-hsqml - a Qt5, QtQuick Canvas backend

haskell-cafe - Sat, 02/28/2015 - 10:41pm
Hello, I wrote a Diagrams backend that paints on QtQuick (Qt5) canvases through HsQML. It's somewhat half-baked at this point and I haven't fully tested it, but it's good enough for my puroposes (rendering charts through Chart-diagrams) and I have more urgent things to do right now, so I decided to release it as it is. http://hackage.haskell.org/package/diagrams-hsqml https://github.com/marcinmrotek/diagrams-hsqml https://github.com/marcinmrotek/diagrams-hsqml/issues There's one bug I already know of but have no idea how to fix; namely when rendering charts from Chart-diagrams all text is fully filled, with a properly rendered black tex laid on top of it. This can be worked around by setting the font colour to transparent. Bug reports and help in improving the backend by all means welcome. Best regards, Marcin Mrotek
Categories: Offsite Discussion