News aggregator

Idiom Brackets for GHC (first full proposal)

haskell-cafe - Thu, 02/26/2015 - 11:04pm
Hi all, A few days ago I made a post here to gauge interest in adding idiom brackets to GHC. Response was a bit more mixed than I was hoping, but no one seemed to drastically against the idea, so I've moved forward with a more detailed proposal. You can find the full proposal here: https://ocharles.org.uk/IdiomBrackets.html A particular difference in my proposal from existing solutions comes from my desire to lift almost *all* expressions - with the original syntax - into idiom brackets. This means normal function application and tuples, but also case expressions, let bindings, record construction, record update, infix notation, and so on. At first I was skeptical about this, but I am finding uses for this more and more. I really like how it lets me use the interesting data (that is, whatever is "under" the applicative functor) where it's most relevant - rather than having to build a function and thread that value back through. Examples of this can be seen in my proposal. To prove its use, I've bee
Categories: Offsite Discussion

RankNTypes question

haskell-cafe - Thu, 02/26/2015 - 8:19pm
Hi Cafe, I can't find how can I do this: {-# LANGUAGE RankNTypes #-} example :: forall a. (forall b. b) -> a example = undefined The first `forall` is for cosmetic reasons. If I understand correctly this is a safe and legit function (please correct me if I'm wrong!). I thought that I can just define `example = id` and GHC would do the rest, but alas, that didn't happen. Thanks!
Categories: Offsite Discussion

safe ways how to get head/last of Seq (or Foldablein general)

haskell-cafe - Thu, 02/26/2015 - 4:18pm
Hi, today I was a bit surprised that apparently there is no easy way how to safely get the head element of `Seq` in a point-free way. Of course there is `viewl`, but it seems the data type has no folding function (something like 'foldViewL :: b -> (a -> Seq a -> b) -> b`. Is there any existing function like `Seq a -> Maybe a` to safely retrieve the head (or last) element? If not, I'd suggest to add headMaybe :: (Foldable t) => t a -> Maybe a headMaybe = getFirst . foldMap (First . Just) and similarly lastMaybe to Data.Foldable. Thanks, Petr _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

[ANN] hoodle 0.4

haskell-cafe - Thu, 02/26/2015 - 4:04pm
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 managing 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
Categories: Offsite Discussion

Would you use frozen-base

haskell-cafe - Thu, 02/26/2015 - 3:36pm
Hi, = Introduction (can be skipped) = Recently, I find myself often worried about stability of our ecosystem – may it be the FTP discussion, or the proposed¹ removal of functions you shouldn’t use, like fromJust. While all that makes our language and base libraries nicer, it also means that my chances that code from 3 or 4 years ago will compile without adjustment on newer compilers are quite low. Then I remember that a perl based webpage that I wrote 12 years ago just keeps working, even as I upgrade perl with every Debian stable release, and I’m happy about that. It makes me wonder if I am ever going to regret using Haskell because there, I’d have to decide whether I want to invest time to upgrade my code or simply stop using it. I definitely do not want to stop Haskell from evolving. Maybe we can make a more stable Haskell experience opt-in? This is one step in that direction, solving (as always) only parts of the problem. = The problem = One problem is that our central library "base" is bo
Categories: Offsite Discussion

Masters degree work tip

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

I'll begin to elaborate my masters degree application in Brazil and I got lucky to know a teacher that is a Haskell + type systems enthusiast.

I like Haskell and type systems. Recently I'm working with JavaScript and the full dynamic nature of the language really got my attention. At first, I tought that type safety and static typing were the future of computer science. Now I don't know. JavaScript is a real mess and it simply works. This reminds me of the reasons that Erlang has no static typing.

As it is a masters degree, I won't solve any problem, but I could help give a small step towards something. I just don't know what. I would like to do something related to Haskell and Type systems, any idea of what I could do? Any work in joining dynamic and static type systems somehow? I can see benefits in both sides.

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

Do notation without monads?

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

So, I was thinking about how sometimes do notation simplifies code immensely, and that made me ask why we only have do notation for monads.

For example: I'm working on a program that has the following pattern repeated and nested many times.

random g = (\(x,g2) -> (\(y,g3) -> (Position (y,x),g3)) (random g2)) (random g)

I turned it into this:

(|>) = flip $ random g = random g |> \(x,g2) -> random g2 |> \(y,g3) -> (Position (y,x),g3)

Which is ok, but it would be so much nicer to be able to write it like this:

random g = do (x,g2) <- random g (y,g3) <- random g2 Position (y,x)

Are there any disadvantages to having do notation outside of a monad?

submitted by MrNosco
[link] [33 comments]
Categories: Incoming News

The `is` library

Haskell on Reddit - Thu, 02/26/2015 - 9:14am

I just discovered the is library on hackage, and for the right problem domain, it's a very handy tool. It just does TH generation to make functions like isRed, isGreen, isBlue (for some data type Color with the constructors Red, Green, and Blue). I was wondering if anyone knows of a more comprehensive library that offers the same feature.

submitted by andrewthad
[link] [18 comments]
Categories: Incoming News

[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