News aggregator

Haskell Generics and Java Reflection

Haskell on Reddit - Mon, 06/22/2015 - 7:53pm

I stumbled on Haskell's Generics and it kind of reminds me of Java's Reflection mechanism. Not exactly the same mechanics in play, but both are trying to "solve" the same problem. Did I get it right?

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

RebindableSyntax on individual do blocks

haskell-cafe - Mon, 06/22/2015 - 7:39pm
I have a program that uses both monads and indexed monads, and I'd like to use do-notation for each in the same source file. Is there a way to rebind syntax for only the do blocks that make use of an indexed monad? Thanks, Mark _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Functional Programming and Safety

Haskell on Reddit - Mon, 06/22/2015 - 6:27pm

In general, does what Functional Programming and Haskell teach result in safer code in other imperative or procedural programming languages? (less bugs etc)

submitted by pragm
[link] [19 comments]
Categories: Incoming News

Turning Monoids into Categories

haskell-cafe - Mon, 06/22/2015 - 5:51pm
Is there a newtype defined in some normal sort of place for turning Monoids into Categories? I'm looking for something like this: newtype ConstConst m a b = ConstConst m instance Monoid m => Category (ConstConst m) where id = ConstConst mempty ConstConst x . ConstConst y = ConstConst (x <> y) Thanks, David Feuer
Categories: Offsite Discussion

Powerset implementation - help with IO system

Haskell on Reddit - Mon, 06/22/2015 - 3:25pm


Im doing some cold-golf challenges (program should be as short as possible) and im stuck now. I have 3 powerset implementations :

powerset [] = [[]] powerset (x:xs) = xss ++ map (x:) xss where xss = powerset xs main = print $ powerset([1,2]) import Control.Monad(filterM) p = filterM(const[True,False]) main = p[1,2] import Data.List; main = (readLn :: IO [Integer] ) >> = print . subsequences

For now it takes an input in this form : [1,2,3]. Any advice how to change it so it takes every number in list in this form :

1 <enter>

2 <enter>

3 <enter>

IO system of haskell is super hard for me, so can someone show me how to make input possible in first and second function ?

Extra question IS it possible to change those function so they compute power set when as one parameter I will pass [1,2] ?

submitted by Cosaquee
[link] [5 comments]
Categories: Incoming News

ANNOUNCE: fgl-arbitrary

General haskell list - Mon, 06/22/2015 - 2:21pm
I've just released the first version of fgl-arbitrary [1], which provides Arbitrary instances for fgl graphs for use with QuickCheck. Also provided are some wrapper newtypes to produce specific types of graphs, and also the ability to generate just valid node and edge lists for use with other graph-like data structures. [1]:
Categories: Incoming News

In what ways does Haskell support intersection and union types?

Haskell on Reddit - Mon, 06/22/2015 - 12:16pm

I read that there was some work about adding support for intersection and union types done in ML (refinement intersection types) and also work on unrestricted intersection types.

Also, I am aware about LiquidHaskell and Dana Xu's work.

However, how much of that can be used in Haskell today (with 7.10)? Anything planned for the future?

Are Haskell's typeclasses one implementation of refinement types?

EDIT: A quote about using intersections and unions for overloading: "In its present form, this idiom is less powerful than type classes (Wadler and Blott 1989)".

Indeed, adding multiple class constraints creates an intersection (Eq a, Show a) => ... means having both Eq and Show.

submitted by mallai
[link] [17 comments]
Categories: Incoming News

Free monads?

Haskell on Reddit - Mon, 06/22/2015 - 11:24am

I would like to understand what a free monad actually is, and who invented the idea, and when.

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

Philip Wadler: How badly will Audible misuse my contact list?

Planet Haskell - Mon, 06/22/2015 - 10:54am

In today's world, where our books, music, and photos belong to the Cloud rather than to ourselves, one problem we face is commercial concerns insisting on increased access to personal data.

I received the following note from Audible:

It looks like you may have an older version of Audible app installed on your device which needs to be updated before 6/30/15 to ensure that you enjoy uninterrupted access to your library.
Option 1: Continue to use the older version of the app.If you receive an error message when you attempt to sign in, look in your emails for a password that you will need for sign in.
Option 2 (Recommended): Upgrade to the latest version....

Warmest Regards,
The Audible TeamWhat the note doesn't mention is that updating the app requires giving Audible access to my contacts list.

Does anyone know how Audible is using the contact list? Worst case scenario is they email advertisements to my friends in my name, telling them what I am currently reading.

Do customers have any legal redress? Changing the terms of service to require access to the customer's contact list is the sort of thing the law should protect against.

Categories: Offsite Blogs

Help to model similar/shrinkable records.

Haskell on Reddit - Mon, 06/22/2015 - 8:09am

I'm working on a simple PAYROLL tool to help my company. At the moment we have a matrix on sheet of paper where every member of write it's time attendance down. The payroll department process manually those sheets and feed our different system (PAYE, Accounting software) also manually. This is time consuming and error prone, so I dediced to a write a tool which allows to enter the data in a file in a "fast format" and generate different reports and csv which can be used to feed the different systems.

So far so good, I've finished the parser I need to generate the different reports/csv which are nearly the same but slightly different. Usually I have an "extensible record" problem, (.i.e how to extend a record). Today I have the opposite the "shrinkable record" problem , how to shrink it down.

The result of the parsing gives a list of Shift

data Shift = Shift { employee :: Employee , day :: Day , startTime :: Maybe TimeOfDay , duration :: Double , hourlyRate :: Double }

startTime is a Maybe because it might be on original sheet or not (people might write 08:00-12:00) or just 4.00 (for 4 hours).

The first task is to get the number of hours per employe/per day. It seems easy, just group by employee/day and aggregate everything else. The grouping is easy, that's the aggregating which causes problem : I know how to solve the problem in lots of dirty way but I haven't found a neat and practical solution.

The first thing I'm thinking is to use a Monoid and do reduce all the similar shifts using mcat. Can I write a valid instance of Monoid for Shift ? Let's focus on the mappend first.

All the employes and days are supposed to be the same (within my list) so I could cheat and just keep the first one. The start time doesn't really make any sense so I could just put Nothing or get the earliest one. Duration it's easy .Hourly rate is fine if each employe always have the same hourly rate. However it might be not the case with extra hours etc .

mempty is even more tricky. However I probably can cheat again and use a dummy Employe or even undefined and set it back at the end. That's not really satisfying.

So, first deception: Shift is not a Monoid, in fact not even a Semigroup, even though I could write it easily in SQL ... so let's try the SQL

SELECT employee, day, sum(duration) AS duration, sum(duration*hourlyRate) AS cost FROM shifts GROUP BY employee, day

That was easy, why is it so hard to do the same in Haskell ? (disclaimer : I don't want to use SQL, I just want to parse a file, and generate a CSV).

Hey, I have changed the type without noticing it (I have dropped startTime and mutate hourlyRate to cost).

So I do modelize this newtype ? Here are my options

type ShiftT = (Employee, Day, Double, Double) data Shift' = Shift' { employee :: Employee , day :: Day , duration :: Double , cost :: Double } data ShiftF f = ShiftF { employee :: f Employee , day :: f Day , duration :: Double , cost :: Double } data ShiftK k = ShiftK { key :: k , duration :: Double , cost :: Double } type ShiftEmpDay = ShiftK (Employee, Day) data Shift'' = { duration :: Double, cost :: Double } type ShiftEmpDay' = ((Employee, Day), Shift'')

etc ...(There is also a solutions using lenses and makeClassy to embed a Shift'' inside a ClassyShift)

Shift' seems fine but It's not a Monoid either, because of Employe and Day (neither than ShiftT). This is frustrating because it's the equivalent to the SQL query but their is not safe way in haskell to guarantee that the Employee/Day will be unique. ShiftK and ShiftF can be a Monoid providing k or f are. ((Employee, Day), Shift'', is not but Shift'' this solution is sort of the easier to implement.

Writting I probabaly would go now for ShiftK, but which approach would you recommend (knowing that once I've done that I'll need also to shrink it again and discard day to get the number of hours/cost per week) ? Is there a better solution ?

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

Am I the only one dissatisfied with the new Hayoo?

Haskell on Reddit - Mon, 06/22/2015 - 6:55am

I always preferred Hayoo to Hoogle as my go-to haddock search engine. But after the new upgrade I feel that it is just broken.

Example given, searching the documentation for Data.Sequence:

Now I see that "seq" and "sequence" are quite overloaded here ... but seeing that there are results like Bio.Core.Sequence and Sequence :: ASN1ConstructionType on the first page I just can wonder. The third try is especially dissatisfying ... after spelling out the complete name of the thing I am searching for I don't get any link to the correct module.

I feel that compared to the "old hayoo" this is just wrong ... is there a good reason for this?

submitted by goliatskipson
[link] [23 comments]
Categories: Incoming News

Daniil Frumin: Darcs binaries for OSX with Homebrew

Planet Haskell - Mon, 06/22/2015 - 6:33am

Recently I’ve updated my Darcs homebrew build to Darcs 2.10. You can install it with

brew install

The formula contains a context (--exact-version) and it is a static binary.

Tagged: darcs, haskell, homebrew
Categories: Offsite Blogs

Mark Jason Dominus: My week at Recurse Center

Planet Haskell - Mon, 06/22/2015 - 4:49am

In late April I served a residency at Recurse Center, formerly known as Hacker School. I want to write up what I did before I forget.

Recurse Center bills itself as being like a writer's retreat, but for programming. Recursers get better at programming four days a week for three months. There are some full-time instructors there to help, and periodically a resident, usually someone notable, shows up for a week. It's free to students: RC partners with companies that then pay it a fee if they hire a Recurser.

I got onto the RC chat system and BBS a few weeks ahead and immediately realized that it was going to be great. I am really wary about belonging to groups, but I felt like I fit right in at RC, in a way that I hadn't felt since I went off to math camp at age 14. Recurse Center isn't that different from math camp now that I think about it.

The only prescribed duty of a resident is to give a half-hour talk on Monday night, preferably on a technical topic. I gave mine on the history and internals of lightweight hash structures in programming languages like Python and Perl. (You can read all about that if you want to.)

Here's what else I did:

  1. I gave a bunch of other talks: two on Git, one on calculating with continued fractions, one on how the Haskell type inferencer works, one on the topology of data types, one on the Unix process model, one on Alien Horrors from the Dawn of Unix. This was too many talks. I didn't have enough energy and time to prepare all of them properly. On the other hand, a lot of people were very complimentary about the talks and said they were very glad that I gave so many. Also, giving talks is a great way to get people familiar with you so that they won't be shy about talking to you or asking you to work with them. But I think I'll cut it down to one per day next time.

  2. Alex Taipale was inspired by my hash talk to implement hashes synthetically in Python, and I paired with her on that for the first part and reviewed her code a couple of times after. It was really fun to see how she went about it.

  3. Libby Horacek showed me around the text adventure game she wrote in Haskell. I had the first of several strokes of luck here. Libby had defined an input format to specify the room layout and the objects, and I observed that it was very similar to Asherah, a project that another Recurser, Michelle Steigerwalt, had done a couple of years before. I found this out because I read everyone's self-posted bio ahead of time and browsed the interesting-sounding links.

  4. Aditya Mukerjee was implementing Git in Go. He wanted help deciphering the delta format. Later I paired with Aditya again and we debugged his implementation of the code that expanded the deltas back into complete files. I hadn't known any Go but it's easy to pick up.

  5. Geoffrey Gilmore had read my ancient article on how to write a regex matcher. He had written his own implementation in Scala and wanted to show it to me. I didn't know any Scala but the code was very clear. Geoffrey had worked out a clever way to visualize the resulting finite automaton: his automaton object had a method that would dump out its graph in the "dot" language, and he could feed that to Graphviz to get it to draw the graph.

  6. I had a conference with Ahmed Abdalla and Joel Burget about SML. The main question they wanted me to answer: Why might they want to look at SML instead of Haskell? This was a stroke of luck: I was unusually well-prepared to answer this question, having written many thousands of lines of SML since about 1993. My answer was unequivocally that there was no reason, SML was obsolete, because it had big problems which had never been solved, and Haskell had been introduced in part to solve, avoid, or finesse these problems.

    For example, nobody knows how to incorporate references into a Hindley-Milner type system. SML has tried at least three methods for doing this over the years. They all suck, and none of them work right. Haskell avoids the whole issue: no references. If you want something like references, you can build a monad that simulates it locally.

    I could probably write a whole blog article about this, so maybe another time.

  7. Libby wanted to pair with me again. She offered me a choice: she was building an e-reader, controlled by a Raspberry Pi, and mounted inside an antique book that she had hollowed out. I would have been willing to try this, although I didn't know anything about Raspberry Pi. But my other choice was very attractive: she was reviving KiSS, an ancient Windows paper-doll app that had been current in the 1990s. people had designed hundreds or thousands of dolls and costumes, which were all languishing because nobody wanted to run the app any more. She wanted to reimplement the dress-up program in Javascript, and port the doll and clothing cels to PNG files. Here I had another stroke of luck. I was already familiar with the program, and I think I have even been into its source code at some point.

    Libby had found that Gimp could load a KiSS cel, so we looked at the Gimp source code to figure out the file format. She had been planning to use libpng to turn the cel into a PNG, but I showed her a better way: convert it into a PPM file and feed to to ppmtopng. This saved a lot of trouble! (I have written a little bit about this approach in the past.) Libby hacked in the Gimp code, grafting her PPM file writing code into the Gimp cel reading code in place of Gimp's internal pixmap operations. It worked!

  8. I talked to Chris Ball about his GitTorrent project. Chris wants to make a decentralized github that doesn't depend on the GitHub company or on their technical infrastructure. He spent a long time trying to make me understand why he wanted to do the project at all and what it was for. I think I eventually got it. It also transpired that Chris knows way more about BitTorrent than I do. I don't think I was much help to Chris.

  9. Jesse Chen paired with me to fix the layout problems that have been troubling my blog for years. We redid the ancient table-based layout that I had inherited from Blosxom ten years ago, converting it mostly to CSS, and fixed a bunch of scrolling problems. We also fixed it to be legible on a phone display, which it previously wasn't. Thanks Jesse!

  10. I had a discussion with Michelle Steigerwalt about big-O notation and how you figure out what an algorithm's big-O-ness is, either from counting lines in the source code or the pseudocode, or from running the algorithm on different-size inputs and timing it. It's fun that you can do the static analysis and then run the program and see it produce the results you predicted.

There was a lot of other stuff. I met or at least spoke with around 90% of the seventy or so Recursers who were there with me. I attended the daily stand-up status meetings with a different group each time. I ate lunch and dinner with many people and had many conversations. I went out drinking with Recursers at least once. The RC principals kindly rescheduled the usual Thursday lightning talks to Monday so I could attend. I met Erik Osheim for lunch one day. And I baked cookies for our cookie-decorating party!

It was a great time, definitely a high point in my life. A thousand thanks to RC, to Rachel Vincent and Dave Albert for essential support while I was there, and to the facilitators, principals, and especially to the other Recursers.

Categories: Offsite Blogs

Threepenny or Fay + HTML for a GUI in Haskell

Haskell on Reddit - Sun, 06/21/2015 - 8:02pm

Hello /r/haskell, over the summer I have decided to work on a text editor written in Haskell. I'd like to do something similar to what Lighttable has done, which is use the Web as a UI. However, I'm not sure which of the two options I should choose.

Looking at Fay, it seems like it's basically Haskell that compiles to Javascript, but essentially needs to be mapped to the useful Javascript functions by hand. It also seems that some of the standard Haskell functions aren't fully implemented yet, and I'd like to be able to keep everything in idiomatic Haskell.

My other option is Threepenny, which basically serves as a small server that serves up HTML that can be written using Haskell functions. However, the project seems not to have as much community backing as Fay, and I'm worried that it may die.

So, do you have any experience with either of these two options? Which one do you think would be best?

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

A look back at Bayhac 2015

Haskell on Reddit - Sun, 06/21/2015 - 5:45pm
Categories: Incoming News