News aggregator

Comparison between fields of each record

haskell-cafe - Tue, 11/24/2015 - 8:20pm
Dear All. I'd like to compare fields of each record. here is my record. data Person = Person {name:: String, age:: Int } deriving(Show) data Relations = Friend | Older | Younger class Comparison a where compare:: a -> a -> Relations instance Comparison Person where compare Person a b Person a b | b1 == b2 = Friend | b1 > b2 = Older | b1 < b2 = Younger How can I fit it? Sincerely, Jeon-Young Kang _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Fast way to serialize Haskell objects

Haskell on Reddit - Tue, 11/24/2015 - 7:58pm

I am using the binary package to write a large Haskell object into and read it from the redis cache. I compress the data using Snappy before writing the bytes into the cache. Snappy compresses the data about 4 to 5 times. It takes about 35 seconds in my case to write the whole thing. I wonder if there is any other serialization package that is faster than binary. Since I am reading the object using the same program, I don't need any extra feature such as interoperability between Haskell and other languages.

I also used protocol buffers to serialize data with no compression. The uncompressed size of data in ProtoBuf is almost the same as the compressed binary. The running time is about the same as well.

submitted by gtab62
[link] [28 comments]
Categories: Incoming News

[ANN] Linode package

haskell-cafe - Tue, 11/24/2015 - 7:51pm
Hello everybody, I'm happy to announce the initial release of the Linode package. It contains bindings to the Linode API and a few user friendly routines to setup and destroy VPS instances. The next major release will cover private IPs and load balancing. Hackage: Github: A working example is provided in the docs. It creates one linode instance and performs a dummy install: Use cases include: - Running some daily batch, with one or several instances - Dynamically adding some resources to a long running process - Anything you would normally do with a VPS Ideas, contributions and feedback are welcome! -- Sebastian de Bellefon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Douglas M. Auclair (geophf): (Really) Big Data: from the trenches

Planet Haskell - Tue, 11/24/2015 - 7:23pm
Okay, people throw around 'big data' experience, but what is it really like? What does it feel like to manage a Petabyte of data. How do you get your hands around it? What is the magic formula that makes it all work seamlessly without Bridge Lines opened on Easter Sunday with three Vice Presidents on the line asking for status updates by the minute during an application outage?

Are you getting the feel for big data yet?


Big data is not terabytes, 'normal'/SQL databases like Oracle or DB2 or GreenPlum or whatever can manage those, and big data vendors don't have a qualm about handling your 'big data' of two terabytes even though they are scoffing into your purchase order.

"I've got a huge data problem of x terabytes."

No, you don't. You think you do, but you can manage your data just fine and not even make Hadoop hiccough.

Now let's talk about big data.

1.7 petabytes
2.5 billion transactions per day.
Oh, and growing to SIX BILLION transactions per day.

This is my experience. When the vendor has to write a new version of HBase because their version that could handle 'any size of data, no matter how big' crashed when we hit 600 TB?

Yeah. Big data.

So, what's it like?

Storage Requirements/Cluster Sizing
1. Your data is bigger than you think it is/bigger than the server farm you planned for it.

Oh, and 0. first.

0. You have a USD million budget ... per month.

Are you still here? Because that's the kind of money you have to lay out for the transactional requirements and storage requirements you're going to need.

Get that lettuce out.

So, back to 1.

You have this formula, right? from the vendor that says: elastic replication is at 2.4 so for 600 TB you need 1.2 Petabytes of space.


Wrong. Wrong. WRONG.

First: throw out the vendors' formulae. They work GREAT for small data in the lab. They suck for big data IRL.

Here's what happens in industry.

You need a backup. You make a backup. A backup is the exact same size as your active HTables, because the HTables are in bz2-format already compressed.

Double the size of your cluster for that backup-operation.

Not a problem. You shunt that TWO PETABYTE BACKUP TO AWS S3?!?!?

Do you know how long that takes?

26 hours.

Do you know how long it takes to do a restore from backup?

Well, boss, we have to load the backup from S3. That will take 26 hours, then we ...

Boss: No.

me: What?

Boss: No. DR ('disaster recovery') requires an immediate switch-over.

Me: well, the only way to do that is to keep the backup local.

Boss: Okay.

Double the size of your cluster, right?


What happens if the most recent backup is corrupted, that is, today's backup, because you're backing up every day just before the ETL-run, then right after the ETL-run, because you CANNOT have data corruption here, people, you just can't.

You have to go to the previous backup.

So now you have two FULL HTable backups locally on your 60-node cluster!

And all the other backups are shunted, month-by-month, to AWS S3.

Do you know how much 2 petabytes, then 4 petabytes, then 6 petabytes in AWS S3 costs ... per month?

So, what to do then?

You shunt the 'old' backups, older than x years old, every month, to Glacier.

Yeah, baby.

That's the first thing: your cluster is 3 times the size of what it needs to be, or else you're dead, in one month. Personal experience bears this out: first you need the wiggle room or else you stress out your poor nodes of your poor cluster, and you start getting HBase warnings and then critical error messages about space utilization, second, you need that extra space when the ETL job loads in a billion row transaction of the 2.5 billion transactions you're loading in that day.

Been there. Done that.

Disaster Recovery
Okay, what about that DR, that Disaster Recovery?

Your 60 node cluster goes down, because, first, you're not an idiot and didn't build a data center and put all those computers in there yourself, but shunted all that to Amazon and let them handle that maintenance nightmare.

Then the VP of AWS Oregon region contacts you and tells you everything's going down in that region: security patch. No exceptions.

You had a 24/7 contract with 99.999% availability with them.

Sorry, Charlie: you're going down. A hard shutdown. On Thursday.

What are you going to do?

First, you're lucky if Amazon tells you: they usually just do it and let you figure that out on your own. So that means you have to be ready at any time for the cluster to go down with no reason.

We had two separate teams monitoring our cluster: 24/7. And they opened that Bridge Line the second a critical warning fired.

And if a user called in and said the application was non-responsive?

Ooh, ouch. God help you. You have not seen panic in ops until you see it when one user calls and come to find it's because the cluster is down with no warning catching that.

Set up monitoring systems on your cluster. No joke.

With big data, your life? Over.

Not an issue. Or, it becomes an issue when you're shunting your backup to S3 and the cluster gets really slow. We had 1600 users that we rolled out to, we stress-tested it, you know. Nobody had problems during normal operations, it's just that when you ask the cluster to do something, like ETL or backup-transfer, that engages all disks of all nodes in reads and writes.

A user request hits all your region servers, too.

Do your backups at 2 am or on the weekends. Do your ETL after 10 pm. We learned to do that.

Amazon is perfect; Amazon is wonderful; you'll never have to maintain nor monitor your cluster again! It's all push-of-the-button.

I will give Amazon this: we had in-house clusters with in-house teams monitoring our clusters, 'round the clock. Amazon made maintenance this: "Please replace this node."

Amazon: "Done."

But you can't ask anything other than that. Your data on that node? Gone. That's it, no negotiations. But Hadoop/HBase takes care of that for you, right? So you're good, right?

Just make sure you have your backup/backout/DR plans in place and tested with real, honest-to-God we're-restarting-the-cluster-from-this-backup data or else you'll never know until you're in hot water.

Every vendor will promise you the Moon ... and 'we can do that.' Every vendor believes it.

Then you find out what's what. We did. Multiple times, multiple vendors. Most can't handle our big data when push came to shove, even though they promised they can handle data of any size. They couldn't. Or they couldn't handle it in a manageable way: if the ETL process takes 26 hours and it's daily, you're screwed. Our ETL process got down to 1.5 hours, but that was after some tuning our their part and on ours: we had four consultants from the vendor in-house every day for a year running. Part of our contract-agreement. If you are blazing the big data trail, your vendor is, too: we were inventing stuff on the fly just to manage the data coming in, and to ensure the data came out in quick, responsive ways.

You're going to have to do that, too, with real big data, and that costs money. Lots.

And, ... but it also costs cutting through what vendors are saying to you, and what their product can actually handle. Their sales people have their sales-pitch, but what really happened is we had to go through three revisions of their product just so it could be an Hadoop HBase-compilant database that could handle 1.7 petabytes of data.

That's all.

Oh, and grow by 2.5 billion rows per day.

Which leads to ...

Backout/Aging Data
Look, you have big data. Some of it's relevant today, some of it isn't. You have to separate the two, clearly and daily, if you're not, then a month, two months, two years down the road you're screwed, because you're now dealing with a full-to-the-gills cluster AND having to disambiguate data you've entangled, haven't you? with the promise of looking at aging data gracefully ... 'later.'

Well, later is right now, and your cluster is full and in one month it's going critical.

What are you going to do?

Have a plan to age data. Have a plan to version data. Have a data-correction plan.

These things can't keep being pushed off to be considered 'later' because 'later' will be far too late, and you'll end up crashing your cluster (bad) or corrupting your data when you slice and dice it the wrong way, come to find (much, much worse). Oh, and version your backups, tying them to the application version, because when you upgrade your application, your data gets all screwy, being old, or your new data format on your old application when somebody pulls up a special request to view three-year-old data is all screwy.

Have a very clear picture of what your users need, the vast majority of the time, and deliver that and no more.

We turned a 4+hour query that terminated when it couldn't deliver a 200k+ row query on GreenPlum...

Get that? 4+hours to learn your query failed.

No soup for you.

To a 10 second query against Hadoop HBase that returns 1M+ rows.

Got that?

We changed peoples' lives. What was impossible before for our 1600 users was now in hand in 10 seconds.

But why?

Because we studied all their queries.

One particular query was issued 85% of the time.

We built our Hadoop/HBase application around that, and shunted the other 15% of the queries other tools that could manage that load.

Also, we studied our users: all their queries were in transactions of within the last month.

We kept two years of data on-hand.


And that two years grew to more, month by month.


We had no graceful data aging/versioning/correcting plans, so, 18 months into production we were faced with a growing problem.

Growing daily.

The users do queries up to a month? No problem: here's your data in less than 10 seconds, guaranteed. You want to do research, you put in a request.

Your management has to put their foot down. They have to be very clear what this new-fangled application is delivering and the boundaries on what data they get.

Our management did, for the queries, and our users loved us. You put in a query and it takes four hours, and only 16 queries are allowed against the system to run at any one time to: anyone, anywhere can submit a query and it returns right away?

Life-changing, and we did psychological studies as well as user-experience studies, too, so I'm not exaggerating.

What our management did not do is put bounds on how far back you could go into the data set. The old application had a 5 year history, so we thought two years was good. It wasn't. Everybody only queried on today, or yesterday, or, rarely: last week or two weeks ago. We should have said: one month of data. You want more, submit a request to defrost that old stuff. We didn't and we paid for it in long, long meetings around the problem of how to separate old data from new and what to do to restore old data, if, ever (never?) a request for old data came. If we had a monthly shunt to S3 then to Glacier, that would have been a well-understood and automatic right-sizing from the get-go.

You do that for your big data set.

Last Words
Look. There's no cookbook or "Big Data for Dummies" that is going to give you all the right answers. We had to crawl through three vendors to get to one who didn't work out of the box but who could at least work with us, night and day, to get to a solution that could eventually work with our data set. So you don't have to do that. We did that for you.

You're welcome.

But you may have to do that because you're using Brand Y not our Brand X or you're using Graph databases, not Hadoop, or you're using HIVE or you're using ... whatever. Vendors think they've seen it all, and then they encounter your data-set with its own particular quirks.

Maybe, or maybe it all will magically just work for you.

And let's say it does all magically work, and let's say you've got your ETL tuned, and your HTables properly structured for fast in-and-out operations.

Then there's the day-to-day daily grind of keeping a cluster up and running. If your cluster is in-house ... good luck with that. Have your will made out and ready for when you die from stress and lack of sleep. If your cluster is from an external vendor, just be ready for the ... eh ... quarterly, at least, ... times they pull the rug out from under you, sometimes without telling you and sometimes without reasonably fair warning time, so it's nights and weekends for you to prep with all hands on deck and everybody looking at you for answers.

Then, ... what next?

Well: you have big data? It's because you have Big Bureaucracy. The two go together, invariably. That means your Big Data team is telling you they're upgrading from HBase 0.94 to HBase whatever, and that means all your data can go bye-bye. What's your transition plan? We're phasing in that change next month.

And then somebody inserts a row in the transaction, and it's ... wrong.

How do you tease a transaction out of an HTable and correct it?

An UPDATE SQL statement?

Hahaha! Good joke! You so funny!

Tweep: "I wish twitter had an edit function."

Me: Hahaha! You so funny!

And, ooh! Parallelism! We had, count'm, three thousand region servers for our MapReduce jobs. You got your hands around parallelism? Optimizing MapReduce? Monitoring the cluster as the next 2.5 billion rows are processed by your ETL-job?

And then a disk goes bad, at least once a week? Stop the job? Of course not. Replace the disk (which means replacing the entire node because it's AWS) during the op? What are the impacts of that? Do you know? What if two disks go down during an op?

Do you know what that means?

At replication of 2.4, two bad disks means one more disk going bad will get you a real possibility of data corruption.

How's your backups doing? Are they doing okay? Because if they're on the cluster now your backups are corrupted. Have you thought of that?

Think about that.

And, I think I've given enough experience-from-the-trenches for you to think on when spec'ing out your own big data cluster. Go do that and (re)discover these problems and come up with a whole host of fires you have to put out on your own, too.

Hope this helped. Share and enjoy.

cheers, geophf
Categories: Offsite Blogs

Enable Profiling in Stack?

Haskell on Reddit - Tue, 11/24/2015 - 5:43pm

We're finally upgrading our dev environment. Stack seems pretty use, but I can't figure out how to build to enable +RTS -prof. Using --executable-profiling does something (at least, it takes a very longtime recompiling every library), but trying -prof still complains, so I'm not really sure what it's doing. Anyone got this working?

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

Can someone explain this code example from Learn You a Haskell For Great Good

Haskell on Reddit - Tue, 11/24/2015 - 3:32pm

I'm going through LYaHFGG for fun during my time off. I think I need some help understanding some code.

Code is here:

This code comes from the modules section under "inits"/"tails" section. I'm guessing his implementation is solely to show how to use tails, but I think I'm not understanding something about the fold function.

Would his implementation keep trying every element in the list, reducing it to the size of the 'needle' and testing for equality? Wouldn't every combination after the single take(length needle) be unnecessary?

In general, I'm having a hard time with foldl and foldr. They seem obtuse, and I don't really understand what kind of functionality they provide beyond rewriting existing code. Is that all they do? Also, I get that they are lazy, and how that can be beneficial if the first or last value needs to be calculated first, but I still find myself trying both foldl/foldr and spanl/spanr every time just to make sure. Is there any tricks for knowing which to use?

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

First Haskell project - Tips/Tricks/Improvements wanted!

Haskell on Reddit - Tue, 11/24/2015 - 2:43pm

Hi guys/gals, I am excited to have finally got something working with Haskell, here is the repo. It's a web API using Servant and postgresql-simple hosted on Heroku.

I'd appreciate it, if anyone is bored, take a look and let me know you think! I am sure there is a lot that can be improved. I haven't really had any contact with anyone who programs Haskell except for #haskell (haha!), so anything to go on is good :)

It's not really finished. For example, the documentation still parses straight to markdown and not HTML, there are no tests (argh!), and the API itself is a single end-point.

I was also wondering should I bother to put this onto Hackage? I mean, it's not really a library or anything ... I'd like to do it, but just wondering if it 'fits'.

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

Industrial placement with Haskell.

Haskell on Reddit - Tue, 11/24/2015 - 1:02pm

Hello r/haskell.

As part of my MEng degree in CompSci I have to secure a 6-month internship with a software company running from April through to September. I checked previous /r/haskell posts and found out about Galois Inc and Tsuru Capital. I sent an application to Galois but Tsuru currently has no open position.

Would any of you know of any other company offering a six-month placement that would involve a project/research in Haskell? What about something in an equally awesome functional language?

Thanks for reading this.

submitted by lambda-zeme
[link] [31 comments]
Categories: Incoming News

Figure out differences in build options or inputs with stack snapshot vs. local package?

Haskell on Reddit - Tue, 11/24/2015 - 12:41pm

I have a very puzzling issue involving a project we build with stack. So far the problem only happens on my PCs (I use Gentoo, other developers use other Linux distros).

We are using a patched version of the myself package as a local package (git submodule) and have been using that exact same version for a while. Today i noticed errors in the unit test runs (I have not worked on this project in a couple of weeks before today). MySQL would produce errors about results no longer being usable in random places (different in each run).

After removing the patched copy of the mysql package the error disappeared so I tried to find the differences between the two versions. It turned out the error still happens when I put the exact source code of the current mysql package in there as a local package but when the same package is built as part of the snapshot it is gone.

Oddly enough the libraries (.a and .so files) in the snapshot and the local package are significantly different in size too (20% roughly) despite having the same hash (?) after their version number which I believe indicates all the dependencies were identical.

I removed the whole .stack folder and all .stack-work folders several times and also any other ghc installations in the PATH and the problem is reproducible.

I also built a stack unpack copy of mysql with a new stack.yaml created by stack init and the size is identical to the one in the snapshot copy.

I also tried to add -O0 or -O2 to the mysql.cabal file to see if optimization made a difference here but apparently either it does not or the setting is ignored since nothing changes in behaviour or size.

I also tried hard-coding the one flag mysql has to false in the stack.yaml but that did not make a difference.

I would appreciate any hints on the actual problem but my current immediate concern is to figure out why the libraries in the snapshot and the local package behave differently and are different in size.

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

Could you criticize this minimalist language idea inspired by Haskell

Haskell on Reddit - Tue, 11/24/2015 - 10:58am

I don't like to work with dynamically typed languages (javascript, lua, etc), so I think it could be nice if there was one simple statically typed language which could be easily translated to the most dynamic languages.

Here this language's concept and I would like to hear some criticism.

submitted by dotneter
[link] [46 comments]
Categories: Incoming News

[APLS2015] 2nd Call for Participation

General haskell list - Tue, 11/24/2015 - 12:03am
=== 2nd Call for Participation === Workshop: Advances in Programming Languages and Systems Date: December 15 - 16, 2015 Venue: Frankfurt, Germany Website: Scope: ------ Advances in programming language research increasingly influence the world of software development and big software companies recognize the importance of research areas like functional programming, static program analysis, run-time verification, automated software engineering and debugging as well as automated verification techniques. This workshop is an opportunity to interact with leading international researchers in these areas, to receive crucial impulses, and to cultivate and maintain new and old collaborations and liaisons. The talks will be given by prominent members of the programming languages research community and cover a wide area of topics inside this field. The list of talks can be found below. For further information please visit http
Categories: Incoming News

Haskell + Java not wanting to cooperate with command line calls.

Haskell on Reddit - Mon, 11/23/2015 - 8:40pm


I am running a Java program that will feed my compiled Haskell program a String as an input and give me back some output. I have it using the Runtime exec method.

Here is my Java:

The toString() returns:

"[Point {key=1, x=1, y=1, r=1}, Point {key=2, x=2, y=2, r=3}]"

When I run the Java program, I get an error "processPoints: no parse" so for some reason Haskell isn't able to interpret my input as a valid String with the correct values.

If I manually execute

/bin/processPoints "[Point {key=1, x=1, y=1, r=1}, Point {key=2, x=2, y=2, r=3}]"

Then I get back the right values like I am supposed to.

Does anyone know why Haskell isn't liking the string that Java is feeding it through the exec() method?


EDIT: Here is something useful! I tried telling my Haskell program to putStrLn what String it was given at the beginning and this is what happened:

So it appears that Java isn't even feeding my Haskell program a full string...? Could it be because of my curly braces?

submitted by Kanel0728
[link] [15 comments]
Categories: Incoming News

Define a subset of constructors of an ADT as a new type?

Haskell on Reddit - Mon, 11/23/2015 - 4:44pm

Supposing I have a function:

data Option2 a = Nothing | One a | Two a a

I want to define a “sub” data type like:

data NotNull a = One a | Two a a

Or a bit clearer:

subdata NotNull of Option2 = One | Two

I understand that through data kinds I can promote a constructor to type level, but it seems that I could not combine two types, or define a “sub” kind of a promoted kind:

kind NotNull = 'One | 'Two

so that I can define something like:

process :: forall (i :: NotNull). (a -> b) -> i a -> i b

Are there any extensions that allow me to achieve what I describe? If not, is there a reason for this? I know almost nothing about dependent type, so if this is a feature of dependent type stuff please let me know some keyword to search! : )

Thank you.

Edit: Sorry to be a bit unclear. I am not seeking a solution to the above simple example. What I am working on is a big complex AST—call it T—which, during the multiple stages of transformation, could only use some of T’s constructors. I hope to have some static guarantees to ensure all pattern matchings are exhaustive and at the same time I can silence unnecessary false non-exhaustivity warning. For example, after nodes representing parentheses are removed, the following would be too verbose:

transform (Let x) = … transform (Paren _) = error "impossible"

but these would become unsafe:

transform (Let x) = … transform _ = error "impossible"

as I may add something to my original AST type later.

submitted by minsheng
[link] [21 comments]
Categories: Incoming News