News aggregator

Is there any generic zipper class that works for any traversable free monad?

Haskell on Reddit - Fri, 01/23/2015 - 3:16pm

Since a free monad encapsules a tree structure, is there a generic zipper that works for any traversable free monad? For example:

tree :: Free [] Int tree = Free [ Free [ Free [Pure 1, Pure 2], Free [Pure 3, Pure 4]], Pure 5, Pure 6, Free [Pure 7,Pure 8,Pure 9]] a = root tree b = goDown 0 a c = goDown 1 b d = goDown 1 c e = view d main = print e

Not exactly that, but you get the idea...

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

HDBC installation error

haskell-cafe - Fri, 01/23/2015 - 12:57pm
Hi, I am trying to install HDBC, using the following command. cabal install hdbc and getting the following error. Preprocessing library HDBC-2.4.0.0... [1 of 8] Compiling Database.HDBC.Locale ( Database\HDBC\Locale.hs, dist\build\Database\HDBC\Locale.o ) [2 of 8] Compiling Database.HDBC.SqlValue ( Database\HDBC\SqlValue.hs, dist\build\Database\HDBC\SqlValue.o ) Database\HDBC\SqlValue.hs:265:29: Ambiguous occurrence `defaultTimeLocale' It could refer to either `Data.Time.defaultTimeLocale', imported from `Data.Time' at Database\HDBC\SqlValue.hs:20:1-16 (and originally defined in `time-1.5:Data.Time.Form at.Locale') or `Database.HDBC.Locale.defaultTimeLocale', imported from `Database.HDBC.Locale' at Database\HDBC\SqlValue.hs:22:30-46 (and originally defined in `System.Locale') Seems to be some kind of import conflict. But
Categories: Offsite Discussion

How much math do I need to know to learn Haskell?

Haskell on Reddit - Fri, 01/23/2015 - 12:15pm

I'm looking to expand my horizons away from OOP, and I've heard that Haskell is one of the better languages to learn if you want to understand functional programming.

So far so good, but as I start to read about Haskell, I immediately get the impression that I need to understand a lot of high level math concepts.. To be honest, I haven't done math in ages, and I never managed to pass my Calculus class but I've been doing very well with OOP. However when I look at Haskell online I see terms like the Howard-Curry Equivalence, functors, Kleisli Arrows, beta reduction, Church numerals, Category theory, etc etc, terms that I honestly haven't ever heard of before and whenever I google them I get to something that seems like it's very complicated and needs a lot of math..

So how much math do I need to know to learn Haskell? It seems like a very cool language but I am not very good with maths.

submitted by Enfeathered
[link] [27 comments]
Categories: Incoming News

The "blueprint technique"

Haskell on Reddit - Fri, 01/23/2015 - 12:00pm
Categories: Incoming News

Tips for finding out what module originates a symbol?

Haskell on Reddit - Fri, 01/23/2015 - 10:48am

Hi,

I'm learning Haskell and it's going well but there's one thing where I feel really stupid, but can't find any good info on how to do better: How do I find out which module imports a symbol when I don't have ghci?

E.g. I'm reading http://www.haskellforall.com/2014/04/model-view-controller-haskell-style.html which uses Single. I can't find Single in hoogle or hayoo so look at all the modules' docs on hackage until I find the symbol [1]. That seems very inefficient .. how do other people solve this?

[1] Single is from https://hackage.haskell.org/package/pipes-concurrency-2.0.1/docs/Pipes-Concurrent.html

submitted by realteh
[link] [12 comments]
Categories: Incoming News

Question about making API with Lens compatibility

Haskell on Reddit - Fri, 01/23/2015 - 10:27am

Hello all

I am trying to make an API for working with persisted records. I would very much like to provide a lens-style interface for reads and updates but I'm not sure if it is possible. Given (contrived but only an example):

data City = City { _cName :: String, _cState :: String } data Person = Person { _pName :: String , _pAge :: Int, _pCity :: City }

I would like to provide a function "update" that takes a lens-like thing to perform the update (to both the record and the persisted data). The key point with this function is I would like the lens-like thing to compose multiple updates but only at one level. I.e.

update (pName "Santa Claus" . pAge 65) person

but not

update (pName "Santa Claus" . (pCity . cName "North Pole City")) person

As well there would be a function "select" for retrieving values out of the records. This would take a lens-like thing but it could get nested values, as in:

(name, age, city) <- select (pName . pAge . (cName . pCity)) person

The above can be considered pseudo code as I doubt select can look like this. But the main thing I wanted to know was if lenses can actually update multiple fields at once, select multiple fields at once and if I can restrict the level the operations work on and still stay compatible with the interface.

Also, note that there would be another operation "modify" that update would be based on (and possibly select, but I don't see how give that select is not as restricted).

submitted by nicheComicsProject
[link] [10 comments]
Categories: Incoming News

JP Moresmau: Writing a low level graph database

Planet Haskell - Fri, 01/23/2015 - 10:10am
I've been interested in graph databases for a long time, and I've developed several applications that offer an API close enough to a graph API, but with relational storage. I've also played with off the shelf graph databases, but I thought it would be fun to try an implement my own, in Haskell of course.
I found that in general literature is quite succinct on how database products manage their physical storage, so I've used some of the ideas behind the Neo4J database, as explained in the Graph Databases books and in a few slideshows online.
So I've written the start of a very low level graph database, writing directly on disk via Handles and some Binary instances. I try to use fixed length record so that their IDs translate easily into offsets in the file. Mostly everything ends up looking like linked lists on disk: vertices have a pointer to their first property and their first edge, and in turn these have pointers to the next property or edge. Vertex have pointers to edges linking to and from them.
I've also had some fun trying to implement an index trie on disk.
All in all, it's quite fun, even though I realize my implementations are quite naive, and I just hope that the OS disk caching is enough to make performance acceptable. I've written a small benchmark using the Hackage graph of packages as sample data, but I would need to write the same with a relational backend.

If anybody is interested in looking at the code or even participate, everything is of course on Github!

Categories: Offsite Blogs

mth

del.icio.us/haskell - Fri, 01/23/2015 - 9:59am
Categories: Offsite Blogs

mth

del.icio.us/haskell - Fri, 01/23/2015 - 9:59am
Categories: Offsite Blogs

Unacceptable argument type in foreign declaration:Ptr ()

haskell-cafe - Fri, 01/23/2015 - 9:59am
L.S., I am trying to compile a package that hasn't been updated since 2009 and I get a lot of messages like: Unacceptable argument type in foreign declaration: Ptr () When checking declaration: foreign import stdcall safe "dynamic" prim_System_Win32_Com_Automation_TypeLib_setGuid :: Ptr () -> Ptr () -> Ptr GUID -> IO Int32 How can I correct this? Regards, Henk-Jan van Tuyl
Categories: Offsite Discussion

CIS 194

del.icio.us/haskell - Fri, 01/23/2015 - 9:22am
Categories: Offsite Blogs

CIS 194

del.icio.us/haskell - Fri, 01/23/2015 - 9:22am
Categories: Offsite Blogs

Question about composing Applicatives

Haskell on Reddit - Fri, 01/23/2015 - 8:44am

I've heard it said (for example, here) that one of the advantages of Applicatives over Monads is that they compose. But I haven't seen a CompositeApplicative type or anything like that.

I'm imagining something like this:

newtype CompositeApplicative a1 a2 b = CompositeApplicative (a1 (a2 b)) instance (Applicative a1, Applicative a2) => Functor (CompositeApplicative a1 a2) where fmap f (CompositeApplicative ca) = CompositeApplicative (fmap (fmap f) ca) instance (Applicative a1, Applicative a2) => Applicative (CompositeApplicative a1 a2) where pure b = CompositeApplicative (pure (pure b)) CompositeApplicative ca1 <*> CompositeApplicative ca2 = CompositeApplicative (pure (<*>) <*> ca1 <*> ca2) type MaybeIO = CompositeApplicative Maybe IO

Does that already exist in some standard library somewhere? If not, why not? Like, what's the standard technique for making use of the fact that Applicatives compose?

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

[ANNOUNCE] New release of SBV

General haskell list - Fri, 01/23/2015 - 8:31am
I'm happy to announce a new release of SBV (v4.0); a library for seamlessly integrating SMT solvers with Haskell. https://hackage.haskell.org/package/sbv Most of the changes in this release are due to Brian Huffman of Galois; essentially adding capabilities so end-users can define symbolic bit-vector types that are not natively supported by SBV. For instance, a user can define `SWord17` for representing 17-bit words and use them just like other symbolic types natively supported by SBV. This feature allows SBV to take advantage of arbitrary bit-size decision procedures for bit-vector logics as found in modern SMT solvers, which are becoming increasingly more valuable in (semi-)automated verification of software artifacts. (Note that SBV already supports other basic types such as unbounded Integers, IEEE Floats and Doubles, Rationals, Algebraic reals, and traditional machine word sizes such as Word8/Int8; 16; 32; and 64 symbolically.) We plan to also add automatic support for SWordN/SIntN for arbitra
Categories: Incoming News

thoughtbot/til

del.icio.us/haskell - Fri, 01/23/2015 - 6:30am
Categories: Offsite Blogs