News aggregator

ANNOUNCE postgresql-query and postgresql-config

haskell-cafe - Sun, 03/01/2015 - 2:30pm
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 - Sun, 03/01/2015 - 1:31pm

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] [7 comments]
Categories: Incoming News

Language.JsonGrammar

Haskell on Reddit - Sun, 03/01/2015 - 10:24am
Categories: Incoming News

Dimitri Sabadie: al 0.1.0.2 – documentation and default paths

Planet Haskell - Sun, 03/01/2015 - 10:03am
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 - Sun, 03/01/2015 - 8:09am
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 - Sun, 03/01/2015 - 7:41am

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] [20 comments]
Categories: Incoming News

Library_submissions and Call for Maintainers

libraries list - Sun, 03/01/2015 - 6:39am
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

m4dc4p/cheatsheet · GitHub

del.icio.us/haskell - Sun, 03/01/2015 - 3:00am
Categories: Offsite Blogs

supki/guard-haskell · GitHub

del.icio.us/haskell - Sun, 03/01/2015 - 2:51am
Categories: Offsite Blogs

fujimura/hi · GitHub

del.icio.us/haskell - Sun, 03/01/2015 - 2:25am
Categories: Offsite Blogs

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

is it possible to implement Functor for ByteStringand Text

haskell-cafe - Sat, 02/28/2015 - 9:11pm
I have recently heard that some people want to burn bridges (introducing Foldable and Traversable to Prelude) and I've been wondering if it was possible somehow allow Text and Bytestring like containers to make use of those functions. Something along the lines of import qualified Data.ByteString as BS newtype ByteString' a = ByteString' BS.ByteString type ByteString = ByteString' Word8 instance (ByteString' a ~ ByteString' Word8) => Functor (ByteString') where fmap f (ByteString' bs) = ByteString' $ BS.map f bs Or if DataContexts worked as you would expect. newtype (Word8 ~ a) => ByteString' a = ByteString' BS.ByteString However I couldn't find a solution and I was just wondering if it is possible. P.S. Using GADTS it does actually work for Foldable, but only because it doesn't have to output any ByteStrings. It doesn't work for Functor for instance. data ByteString' a where ByteString' :: BS.ByteString -> ByteString' Word8 type ByteString = ByteString' Word8 instance Foldable ByteSt
Categories: Offsite Discussion

Parallel numeric class hierarchy

haskell-cafe - Sat, 02/28/2015 - 7:28pm
Let's say for arguments sake I want to make a new finer grained numeric class hierarchy. But, I also want to have the following occur: (1) Existing modules which have defined data types which have Num instances can be used with functions in my new hierarchy (2) New data types defined in the new hierarchy automatically get Num instances if appropriate so they can be used in existing modules. I know this is somewhat of a vague question but roughly how would I go about this? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Hackage and Free Software

haskell-cafe - Sat, 02/28/2015 - 7:27pm
Hello haskellers! I would like to make a proposal regarding the license of software in Hackage. One of the major parts of the Haskell community infrastructure in the package database server Hackage. As far as I know - please correct me if I'm wrong - Hackage makes no restriction on the license of packages upload to it. But as a community working in cooperation to make good software, the Haskell community has embraced licenses like (L)GPL, MIT and BSD, which are free software licenses. Actually the all-rights-reserved tag in Hackage [1] has only two packages tagged by it - the dummy no-op project HNop, and another package whose COPYING file contains a broken link and whose README says "BSD style license". Software freedom is an ethical basis for collaboration on making software that's truly good and loayl to its users, and providing them control and freedom to access and use their computing resources. It seems to me that the Haskell community is already enbracing this ethical basis, but Hackage doesn
Categories: Offsite Discussion