News aggregator

[ANN] hoodle 0.4

Haskell on Reddit - Thu, 02/26/2015 - 8:10am

Hi, Haskellers!

I am happy to announce a new version of hoodle that I uploaded to hackage right now. The newest version is 0.4.

Hoodle is a pen notetaking program developed in haskell using gtk2hs. You can find relevant information here: http://ianwookim.org/hoodle

If all the dependencies are correctly installed (hoodle has rather big dependencies though), the installation of hoodle should be easily doable by cabal install hoodle. I am maintaining hoodle in nix package repository, so nix users can also easily install hoodle by nix command once after nix expression in nixpkgs is updated.

The major change in this update is tabbed interface! Like modern web browsers, you can open multiple hoodle files in one hoodle window and navigate them using tabs.

Internally, I improved its rendering engine quite much. Now it has a fully asynchronous renderer, which enables a faster change of zoom ratio using cached image and then update rendering later more precisely. This improves display performance from user's point of view a lot.

I also made a support for synchronisation and shared documents in association with a web service which I am now preparing for. By default, it is turned off, so all network-related dependencies for that will not be required unless turned on by -fhub flag. In addition, I also made dyre (dynamic reloading as xmonad and yi) opt-in, so you need to use -fdyre if you want to have the feature.

Now hoodle is being migrated to gtk3 though this version will not support gtk3 fully yet. I plan to migrate hoodle to gtk3 fully and use gtk3 exclusively in the next version, so this version will be the last gtk2 version. Once this is done, a multi-touch support will be enabled. (and also hoodle will be able to live in wayland, too!)

Enjoy hoodle and please bug me if you have any issues. Thank you!

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

Dimitri Sabadie: Smoothie, a Haskell library for creating smooth curves

Planet Haskell - Thu, 02/26/2015 - 4:55am
The smoother the better!

It’s been a while I haven’t written anything on my blog. A bit of refreshment doesn’t hurt much, what do you think?

As a demoscener, I attend demoparties, and there will be a very important and fun one in about a month. I’m rushing on my 3D application so that I can finish something to show up, but I’m not sure I’ll have enough spare time. That being said, I need to be able to represent smooth moves and transitions without any tearing. I had a look into a few Haskell spline libraries, but I haven’t found anything interesting – or not discontinued.

Because I do need splines, I decided to write my very own package. Meet smoothie, my BSD3 Haskell spline library.

Why splines?

A spline is a curve defined by several polynomials. It has several uses, like vectorial graphics, signal interpolation, animation tweening or simply plotting a spline to see how neat and smooth it looks!

Splines are defined using polynomials. Each polynomials is part of the curve and connected one-by-one. Depending on which polynomial(s) you chose, you end up with a different shape.

For instance, 1-degree polynomials are used to implement straight lines.

As you can see, we can define a few points, and interpolate in between. This is great, because we can turn a discrete set of points into lines.

Even better, we could use 3-degree polynomials or cosine functions to make each part of the spline smoother:

We still have discrete points, but in the end, we end up with a smooth set of points. Typically, imagine sampling from the spline with time for a camera movement. It helps us to build smooth moves. This is pretty important when doing animation. If you’re curious about that, I highly recommend having a look into key frames.

Using splines in Haskell

So I’ve been around implementing splines in Haskell the most general way as possible. However, I don’t cover – yet? – all kinds of splines. In order to explain my design choices, I need to explain a few very simple concepts first.

Sampling

A spline is often defined by a set of points and polynomials. The first point has the starting sampling value. For our purpose, we’ll set that to 0:

let startSampler = 0

The sampling value is often Float, but it depends on your spline and the use you want to make of it. It could be Int. The general rule is that it should be orderable. If we take two sampling values s and t, we should be able to compare s and t (that’s done through the typeclass constraint Ord in Haskell).

So, if you have a spline and a sampling value, the idea is that sampling the spline with startSampler gives you the first point, and sampling with t with t > startSampler gives you another point, interpolated using points of the spline. It could use two points, three, four or even more. It actually depends on the polynomials you use, and the interpolating method.

In smoothie, sampling values have types designed by s.

Control points

A spline is made of points. Those points are called control points and smoothie uses CP s a to refer to them, where s is the sampling type and a the carried value.

Although they’re often used to express the fact that the curve should pass through them, they don’t have to lie on the curve itself. A very common and ultra useful kind of spline is the B-spline.

With that kind of spline, the property that the curve passes through the control points doesn’t hold. It passes through the first and last ones, but the ones in between are used to shape it, a bit like magnets attract things around them.

Keep in mind that control points are very important and used to define the main aspect of the curve.

Polynomials

Polynomials are keys to spline interpolation. They’re used to deduce sampled points. Interpolation is a very general term and used in plenty of domains. If you’re not used to that, you should inquiry about linear interpolation and cubic interpolation, which are a very good start.

Polynomials are denoted by Polynomial s a in smoothie, where s and a have the same meaning than in CP s a.

Getting started with smoothieTypes and constraints

smoothie has then three important types:

  • CP s a, the control points
  • Polynomial, the polynomials used to interpolate between control points
  • Spline s a, of course

The whole package is parameterized by s and a. As said earlier, s is very likely to require an Ord constraint. And a… Well, since we want to represent points, let’s wonder: which points? What kind of points? Why even “points”? That’s a good question. And this is why you may find smoothie great: it doesn’t actually know anything about points. It accepts any kind of values. Any? Almost. Any values that are in an additive group.

“What the…”

I won’t go into details, I’ll just vulgarize them so that you get quickly your feet wet. That constraint, when applied to Haskell, makes a to be an endofunctor – i.e. Functor – and additive – i.e. Additive. It also requires it to be a first-class value – i.e. its kind should be * -> *.

With Functor and Additive, we can do two important things:

  • First, with Functor. It enables us to lift computation on the inner type. We can for instance apply a single function inside a, like *k or /10.
  • Then, with Additive. It enables us to add our types, like a + b.

We can then make linear combinations, like ak + bq. This property is well known for vector spaces.

The fun consequence is that providing correct instances to Functor and Additive will make your type useable with smoothie as carried value in the spline! You might also have to implement Num and Ord as well, though.

Creating a spline

Creating a spline is done with the spline function, which signature is:

spline :: (Ord a, Ord s) => [(CP s a, Polynomial s a)] -> Spline s a

It takes a list of control points associated with polynomials and outputs a spline. That requires some explainations… When you’ll be sampling the spline, smoothie will look for which kind of interpolation method it has to use. This is done by the lower nearest control point to the sampled value. Basically, a pair (cp,polynomial) defines a new point and the interpolation method to use for the curve ahead of the point.

Of course, the latest point’s polynomial won’t be used. You can set whatever you want then – protip: you can even set undefined because of laziness.

Although the list will be sorted by spline, I highly recommend to pass a sorted list, because dealing with unordered points might have no sense.

A control point is created by providing a sample value and the carried value. For instance, using linear’s V2 type:

let cp0 = CP 0 $ V2 1 pi

That’s a control point that represents V2 1 pi when sampling is at 0. Let’s create another:

let cp1 = CP 3.341 $ V2 0.8 10.5

Now, let’t attach a polynomial to them!

Hold that for me please

The simplest polynomial – wich is actually not a polynomial, but heh, don’t look at me that way – is the 0-degree polynomial. Yeah, a constant function. It takes the lower control point, and holds it everwhere on the curve. You could picture that as a staircase function:

You might say that’s useless; it’s actually not; it’s even pretty nice. Imagine you want to attach your camera position onto such a curve. It will make the camera jump in space, which could be desirable for flash looks!

Use the hold Polynomial to use such a behavior.

Oh yeah, it’s straightforward!

1-degree functions often describe lines. That is, linear is the Polynomial to use to connect control points with… straight lines.

Have fun on the unit circle!

One very interesting Polynomial is cosine, that defines a cosine interpolation, used to smooth the spline and make it nicer for moves and transitions.

Highway to the danger zone

If you’re crazy, you can experiment around with linearBy, which, basically, is a 1-degree polynomial if you pass id, but will end up in most complex shapes if you pass another function – (s -> s). Dig in documentation on hackage for further information.

Sampling our spline

Ok, let’s use a linear interpolation to sample our spline:

let spl = spline [(cp0,linear),(cp1,hold)]

Note: I used hold as a final polynomial because I don’t like using undefined.

Ok, let’s see how to sample that. smoothie exports a convenient function for sampling:

smooth :: Ord s => Spline s a -> s -> Maybe a

smooth spl s takes the sampling value s and maybe interpolate it in the spl spline.

“Maybe? Why aren’t you sure?”

Well, that’s pretty simple. In some cases, the curve is not defined at the sampling value you pass. Before the first point and after, basically. In those cases, you get Nothing.

That’s not the end

I wrote smoothie in a few hours, in a single day. You might have ideas. I want it to be spread and widely used by awesome people. Should you do graphics programming, sound programming, animation or whatever implying splines or smoothness, please provide feedback!

For people that would like to get contributing, here’s the github page and the issue tracker.

If no one comes up with, I’ll try to add some cubic interpolation methods, like hermitian splines, and one of my favorite, the famous Catmull Rom spline interpolation method.

As always, have fun hacking around, and keep doing cool stuff and sharing it!

Categories: Offsite Blogs

Haskell Weekly News: Issue 318

haskell-cafe - Thu, 02/26/2015 - 2:59am
New Releases A very fast BufferBuilder-based JSON encoder for Aeson. Encode JSON 2-5x faster than Aeson. https://hackage.haskell.org/package/buffer-builder-0.2.0.3 https://hackage.haskell.org/package/buffer-builder-aeson-0.2.0.3 http://www.reddit.com/r/haskell/comments/2wwbuj/announcing_bufferbuilder_encode_json_25x_faster/ FLTK GUI bindings - Alpha release This library aims to make it easy for users to build native apps that work portably across platforms. http://hackage.haskell.org/package/fltkhs-0.1.0.0/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html Calls for Participation Primitive Haskell Originally this is a chapter in Mezzo Haskell, covering primitive operations, evaluation order and mutation. Michael Snoyman wants feedback on style and teaching approach. https://www.fpcomplete.com/blog/2015/02/primitive-haskell https://github.com/fpco/mezzohaskell Intermediate Haskell documentation proposal Michael Snoyman points out t
Categories: Offsite Discussion

nathankot/wsproxy · GitHub

del.icio.us/haskell - Thu, 02/26/2015 - 2:57am
Categories: Offsite Blogs

nathankot/wsproxy · GitHub

del.icio.us/haskell - Thu, 02/26/2015 - 2:57am
Categories: Offsite Blogs

CFP - SBLP 2015: 19th Brazilian Symposium on ProgrammingLanguages

General haskell list - Thu, 02/26/2015 - 12:51am
CALL FOR PAPERS - SBLP 2015 19th Brazilian Symposium on Programming Languages 21-26 September 2015 Belo Horizonte, Brazil http://cbsoft.org/sblp2015 +++++++++++++++++++++++++++++++++++++++++++++++++++ IMPORTANT DATES Abstract submission: 20 April, 2015 Paper submission: 27 April, 2015 Author notification: 18 June, 2015 Camera ready deadline: 2 July 2015 INTRODUCTION The Brazilian Symposium on Programming Languages is a well-established symposium which provides a venue for researchers and practitioners interested in the fundamental principles and innovations in the design and implementation of programming languages and systems. SBLP 2015 is part of 6th Brazilian Conference on Software: Theory and Practice, CBSoft 2015, that will be held in Belo Horizonte, Minas Gerais, Brazil, from September 21st to September 26th, 2015. Authors are invited to submit original research on any relevant topic which can be either in the form of regular or short papers. TOPICS Topics of interest include, but are not l
Categories: Incoming News

Making withSocketsDo unnecessary

Haskell on Reddit - Thu, 02/26/2015 - 12:51am
Categories: Incoming News

x / 0 = True

Haskell on Reddit - Wed, 02/25/2015 - 9:44pm

As you guys know or not, I'm trying to program games using the Simply Typed Lambda Calculus because of reasons. I noticed it was a great idea as soon as I got a whole day stuck trying to implement div. The church encoding entry on Wikipedia relies on the Y-Combinator, which is not expressible on the STLC. After a lot of googling I learned my Google skills are bad. So I annoyed /u/tekmo, which kindly pointed me to this non-recursive implementation. There it is:

(L a (L b ((((a (L _ (((b (L _ (L c (L sign c)))) (L _ (L m (L sign (L f (L x (sign ((m f) x)))))))) (L _ (L x (L y x)))))) (L _ (((b (L _ (L m (L sign (L f (L x (sign ((m f) x)))))))) (L _ (L c (L sign c)))) (L _ (L x (L y x)))))) (L _ (L sign (L f (L x x))))) (((((a (L x x)) (L u ((((u (L x (L y y))) (L x (L y x))) u) (((((((u (L x (L y x))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ (L sign (L f (L x (sign ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x)))))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (u (L x (L y x)))))) (u (L x (L y x)))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ ((((u (L x (L y x))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x))))))) (L _ (L sign (L f (L x ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x))))))) (u (L x (L y x)))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x))))) (L _ (L p ((p ((((u (L x (L y x))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ (L sign (L f (L x (sign ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x)))))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (u (L x (L y x)))))) (u (L x (L y x)))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ ((((u (L x (L y x))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x))))))) (L _ (L sign (L f (L x ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x))))))) (u (L x (L y x)))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))))) (L p ((p (L x (L y x))) ((u (L x (L y y))) (L x (L y y))))))))) (L _ (L p ((p ((((u (L x (L y x))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ (L sign (L f (L x (sign ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x)))))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (u (L x (L y x)))))) (u (L x (L y x)))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ ((((u (L x (L y x))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x))))))) (L _ (L sign (L f (L x ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x))))))) (u (L x (L y x)))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))))) (L p ((p (L x (L y y))) (L f (L x (f ((((u (L x (L y y))) (L x (L y y))) f) x)))))))))) (L p ((p ((((u (L x (L y x))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ (L sign (L f (L x (sign ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x)))))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (u (L x (L y x)))))) (u (L x (L y x)))))) (L _ ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L _ ((((u (L x (L y x))) (L x x)) (L a (((a (L _ (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g73 (L x (L f (L x x))))) (L _ (L sign (L f (L x (sign (((((a (L x x)) (L z ((z (L x x)) (L f (L x (f ((z f) x))))))) (L g74 (L x (L f (L x x))))) f) x))))))) (L sign (L f (L x x)))))) (L _ (L sign (L f (L x (f (((a (L x x)) f) x))))))) (L sign (L f f))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x))))))) (L _ (L sign (L f (L x ((((u (L x (L y x))) (L x x)) f) ((((((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))) (L x x)) f) x))))))) (u (L x (L y x)))))) (((b (L x x)) (L _ (L sign (L f (L x (sign (((b (L x x)) f) x))))))) (L sign (L f (L x x)))))) (L p ((p (L x (L y x))) (L f (L x (f ((((u (L x (L y y))) (L x (L y y))) f) x)))))))))))) (L p ((p (L sign (a (L x x)))) (L p ((p (L x (L y y))) (L f (L x x))))))) (L x (L y y))) (L x (L y y))))))

I found it too big for my tastes, so I continued trying to make my own. After a few years wasted and a lot of vodka, I accidentally dropped my notebook on the floor and, when I picked it up, I happened to have this written on the screen:

(λ (λ ((((1 (λ (λ ((1 (λ ((0 (λ (λ (1 ((((4 (λ 0)) (λ (λ 1))) 1) 0))))) 1))) (λ (λ 0)))))) ((0 (λ (λ (λ ((0 (λ (λ 0))) (2 1)))))) (λ 0))) (λ 0)) (λ (λ 1)))))

Which luckily worked:

Lambda> let div = (λ (λ ((((1 (λ (λ ((1 (λ ((0 (λ (λ (1 ((((4 (λ 0)) (λ (λ 1))) 1) 0))))) 1))) (λ (λ 0)))))) ((0 (λ (λ (λ ((0 (λ (λ 0))) (2 1)))))) (λ 0))) (λ 0)) (λ (λ 1))))) # 4 / 2 = 2 Lambda> div (λ (λ (1 (1 (1 (1 0)))))) (λ (λ (1 (1 0)))) (λ (λ (1 (1 0)))) # 6 / 2 = 3 Lambda> div (λ (λ (1 (1 (1 (1 (1 (1 0)))))))) (λ (λ (1 (1 0)))) (λ (λ (1 (1 (1 0))))) # 7 / 3 = 2 Lambda> div (λ (λ (1 (1 (1 (1 (1 (1 (1 0))))))))) (λ (λ (1 (1 (1 0))))) (λ (λ (1 (1 0)))) # 7 / 8 = 0 Lambda> div (λ (λ (1 (1 (1 (1 (1 (1 (1 0))))))))) (λ (λ (1 (1 (1 (1 (1 (1 (1 (1 0)))))))))) (λ (λ 0))

According to Occam, the simplest definition is necessarily the better. Also, as far as I know, there is no simpler definition of division on the published literature. Follows, logically, that I get to right claim my division to be The True One ®. This way, now we can finally solve a millennium mystery:

# 7 / 0 = ... Lambda> div (λ (λ (1 (1 (1 (1 (1 (1 (1 0))))))))) (λ (λ 0)) (λ (λ 1))

Turns out division by 0 is true. The true combinator. Any questions?

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

Equivalence of programming languages?(off topic)

Haskell on Reddit - Wed, 02/25/2015 - 8:50pm

I know this post does not belong here. But I want to put it here.

A few days ago, I began to think about what is a good programming language(PL). The post is here. The point is that there is probably no true standard of programming languages. There are different programming paradigms, but there is no saying that what a functional programming language should follow. This makes a programmer with rich experience of Haskell doesn't know the tricks of F#. A C++ programmer will spend more time getting to know what is foreach. What's more, even though two programming languages are Turing equivalent, we cannot convert the source code of one to another without too much pain.

That makes me consider these questions:

  • What a PL of a certain paradigm should adopt basically?
  • What are the chosen programming languages that stands for one paradigm?
  • Are we(you) creating the right programming language?
  • If each programmer writes one part of a project in his own language, how to glue them together?

PS: I hope this post doesn't make the moderators angry.

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

ETAPS 2016 call for satellite events

General haskell list - Wed, 02/25/2015 - 8:47pm
19th European Joint Conferences on Theory and Practice of Software ETAPS 2016 Eindhoven, The Netherlands, April 2-8, 2016 http://www.etaps.org/2016/ Call for Satellite Events
Categories: Incoming News

Joachim Breitner: DarcsWatch End-Of-Life’d

Planet Haskell - Wed, 02/25/2015 - 5:39pm

Almost seven years ago, at a time when the “VCS wars” have not even properly started yet, GitHub was seven days old and most Haskell related software projects were using Darcs as their version control system of choice, when you submitted a patch, you simply ran darcs send and mail with your changes would be sent to the right address, e.g. the maintainer or a mailing list. This was almost as convenient as Pull Requests are on Github now, only that it was tricky to keep track of what was happening with the patch, and it would be easy to forget to follow up on it.

So back then I announced DarcsWatch: A service that you could CC in your patch submitting mail, which then would monitor the repository and tell you about the patches status, i.e. whether it was applied or obsoleted by another patch.

Since then, it quitely did its work without much hickups. But by now, a lot of projects moved away from Darcs, so I don’t really use it myself any more. Also, its Darcs patch parser does not like every submissions by a contemporary darcs, so it is becoming more and more unreliable. I asked around on the xmonad and darcs mailing lists if others were still using it, and noboy spoke up. Therefore, after seven years and 4660 monitored patches, I am officially ceasing to run DarcsWatch.

The code and data is still there, so if you believe this was a mistake, you can still speak up -- but be prepared to be asked to take over maintaining it.

I have a disklike for actually deleting data, so I’ll keep the static parts of DarcsWatch web page in the current state running.

I’d like to thank the guys from spiny.org.uk for hosting DarcsWatch on urching for the last 5 years.

Categories: Offsite Blogs

What is an indexed monad?

Haskell on Reddit - Wed, 02/25/2015 - 4:55pm
Categories: Incoming News

Neil Mitchell: Making withSocketsDo unnecessary

Planet Haskell - Wed, 02/25/2015 - 4:11pm

Summary: Currently you have to call withSocketsDo before using the Haskell network library. In the next version you won't have to.

The Haskell network library has always had a weird and unpleasant invariant. Under Windows, you must call withSocketsDo before calling any other functions. If you forget, the error message isn't particularly illuminating (e.g. getAddrInfo, does not exist, error 10093). Calling withSocketsDo isn't harmful under Linux, but equally isn't necessary, and thus easy to accidentally omit. The network library has recently merged some patches so that in future versions there is no requirement to call withSocketsDo, even on Windows.

Existing versions of network

The reason for requiring withSocketsDo is so that the network library can initialise the Windows Winsock library. The code for withSocketsDo was approximately:

withSocketsDo :: IO a -> IO a
#if WINDOWS
withSocketsDo act = do
initWinsock
act `finally` termWinsock
#else
withSocketsDo act = act
#endif

Where initWinsock and termWinsock were C functions. Both checked a mutable variable so they only initialised/terminated once. The initWinsock function immediately initialised the Winsock library. The termWinsock function did not terminate the library, but merely installed an atexit handler, providing a function that ran when the program shut down which terminated the Winsock library.

As a result, in all existing versions of the network library, it is fine to nest calls to withSocketsDo, call withSocketsDo multiple times, and to perform networking operations after withSocketsDo has returned.

Future versions of network

My approach to removing the requirement to call withSocketsDo was to make it very cheap, then sprinkle it everywhere it might be needed. Making such a function cheap on non-Windows just required an INLINE pragma (although its very likely GHC would have always inlined the function anyway).

For Windows, I changed to:

withSocketsDo act = do evaluate withSocketsInit; act

{-# NOINLINE withSocketsInit #-}
withSocketsInit = unsafePerformIO $ do
initWinsock
termWinsock

Now withSocketsDo is very cheap, with subsequent calls requiring no FFI calls, and thanks to pointer tagging, just a few cheap instructions. When placing additional withSocketsDo calls my strategy was to make sure I called it before constructing a Socket (which many functions take as an argument), and when taking one of the central locks required for the network library. In addition, I identified a few places not otherwise covered.

In newer versions of the network library it is probably never necessary to call withSocketsDo - if you find a place where one is necessary, let me know. However, for compatibility with older versions on Windows, it is good practice to always call withSocketsDo. Libraries making use of the network library should probably call withSocketsDo on their users behalf.

Categories: Offsite Blogs

Wordlint .0.2.0.0: multiple, intersecting prose redundancy checks

Haskell on Reddit - Wed, 02/25/2015 - 3:27pm

I have updated my prose redundancy-proofing program, Wordlint.

With this comes simplified CLI arguments, one for each type of redundancy check: --words, --lines, and --percent. Additionally, the program can now accept multiple types and will return the intersection of the results of each. For example,

wordlint -w 50 -p 0.5 -f file.txt

will return only pairs of words that are found both within fifty words of each other and within one-half of a percent of the file. This comes with a small sacrifice of data clarity when run with the --human flag, which is more of a novelty/debugging tool anyway.

Thanks for reading and enjoy!

Edit 8:00 pm 2015-02-26: There were some installation issues, so v.0.2.0.4 is up on Hackage with a passing build test. Sorry about the delay everyone!

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

Typed label

haskell-cafe - Wed, 02/25/2015 - 3:12pm
Hi! I have a problem that seems very basic and fundamental, but at the same time I keep somehow skipping "the right way" to solve it. So I decided to give a try and describe it here. The task itself is very common. You have some data, which has some property inside of it. Often, you want to write a function that works only on an object with specific property being equal to something, but you can't move it out to type-parameter, because then you get all sorts of problems like you can't use regular lists/vectors anymore and other similar things. Let's take a look at real-world example to get a better understanding of a problem: Given a `Vegetable` type with a type that describes it's "type" (saying which concretely veg is it), you need to write a function `embraceOnion`, which would only work on onions (because it doesn't make sense to embrace any other veg). https://gist.github.com/k-bx/32b3f6a770ad81330f51 ``` {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} module Main where main :: I
Categories: Offsite Discussion

ajtulloch/caffegraph

del.icio.us/haskell - Wed, 02/25/2015 - 2:44pm
Categories: Offsite Blogs

ajtulloch/caffegraph

del.icio.us/haskell - Wed, 02/25/2015 - 2:44pm
Categories: Offsite Blogs