News aggregator

Warnings with OverloadedLists

haskell-cafe - Mon, 06/16/2014 - 4:19pm
Hello, I've bumped into strange GHC behaviour with OverloadedLists and pattern matching. Consider this example: {-# LANGUAGE OverloadedLists #-} len :: [a] -> Int len [] = 0 len (_:t) = 1 + len t If I load this with "ghci -Wall", I get a warning: Test.hs:4:1: Warning: Pattern match(es) are non-exhaustive In an equation for ‘len’: Patterns not matched: [] If I disable OverloadedLists extension, warning goes away. Can someone clear this behaviour out for me? It looks like a bug, but I'm not sure. Thanks for help, Nikolay. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Romantic Haskell

Haskell on Reddit - Mon, 06/16/2014 - 3:31pm

Not sure if this is the right subreddit for this, but I thought I'd share - I wrote this little poem for my girlfriend on Valentines day:

-- You're one in a million, you = 1 everyoneElse = 999999 -- And I promise I'll stay True == -- And that while you'll take me, takeWhile -- I'll love only you (<3) [you, everyoneElse] == [you]

Of course, the Haskell is supposed to be:

you = 1 everyoneElse = 999999 *Load into GHCi* > True == (takeWhile (<3) [you, everyoneElse] == [you])

It's not perfect, but I like it :)

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

What is GHC 7.8.2 doing here (typed holes, data+poly kinds, type families etc.)

haskell-cafe - Mon, 06/16/2014 - 2:54pm
Hi, I've come across some behaviour in GHC 7.8.2 which seems strange, and may be a bug, but I wish to check before reporting it. Consider the minimum example pasted at the bottom of this message. At the line plusComm (SS m') n' = _ GHC tells me that I have a single hole in the file with type 'S (m1 :+: n) :~: (n :+: 'S m1) which is straightforward to provide, by rewriting with the inductive hypothesis (a recursive call of plusComm) and then some fiddling. However, replacing this line with the refinement plusComm (SS m') n' = substR (plusComm m' n') _ GHC tells me that the remaining hole now has type 'S (m1 :+: n) :~: (m1 :+: n) which seems completely incorrect to me. Shouldn't this hole have type 'S (n :+: m1) :~: (n :+: S m1) ? Can anybody give any clues as to what is happening? Thanks, Dominic {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} module Minim
Categories: Offsite Discussion

Polymorphism in the Prelude

libraries list - Mon, 06/16/2014 - 2:46pm
Hi libraries, Let me try to sum up the general sentiment I've seen: Having lots of polymorphism in the Prelude is great, but for two problems: 1) It's very confusing to novices. 2) In the case of using Control.Category definitions: kind-polymorphism is not portable I wish to ignore (2) for now, as it's a smaller concern given that it affects only a portion of the proposed changes. As a way to mitigate (1), I have been thinking of proposing something almost exactly along the lines of http://comments.gmane.org/gmane.comp.lang.haskell.glasgow.user/23719 (thanks for posting that link -- saved me from writing up the same thing!). But, after reading that thread, I tend to agree that tweaking the module system seems the wrong way to deal with helping novices. In designing my own libraries, my general guideline is to make the easy thing easy and make the hard thing only slightly less easy. Spurred on by Erik Hesselink's comment (http://www.haskell.org/pipermail/libraries/2014-June/023174.html), what if we j
Categories: Offsite Discussion

What does the tensor product operation look like in type theory (if it exists)?

Haskell on Reddit - Mon, 06/16/2014 - 2:03pm

That is to say, if A + B is a type that contains either A or B, and A * B is a type that contains both A and B, then what is A (X) B where (X) is the tensor product, or does it not exist?

submitted by gcross
[link] [8 comments]
Categories: Incoming News

Johan Jeuring: The aftermath

Planet Haskell - Mon, 06/16/2014 - 12:42pm
We are wrapping up our efforts on the ICFP Programming Contest 2007. Most contest-related matters have been finished by now.

If you want to read more about the ICFP Programming contest, you should have a look at our report about it.

You can order a t-shirt with the after picture on the back, and one picture from the arrival sequence on the front from cafepress, or create your own t-shirt using these materials (4.3MB).

If you want to see the presentation we gave about the contest at ICFP 2007, have a look at our video (with an explanation about how to solve the contest problem starting at 18:00, and Endo appearing at around 1:12:00).

The question we got after the contest was: How much time did you spend creating it? We have different answers to this question, but probably the one that comes closest to the truth is: as much as we enjoyed creating it.
Categories: Offsite Blogs

Gibbs Sampling in Haskell

Haskell on Reddit - Mon, 06/16/2014 - 11:59am
Categories: Incoming News

Uploading to hackage fails: bad file names in tarball

haskell-cafe - Mon, 06/16/2014 - 9:44am
Since some time, I have been unable to upload packages to Hackage, via either the 'cabal upload' command, or using the web form. The error message it gives is this: ==== ✂ ==== Hackage username: AriePeterson Hackage password: Uploading dist/np-linear-0.1.1.1.tar.gz... Error: dist/np-linear-0.1.1.1.tar.gz: 400 Bad Request Error: Invalid package Invalid windows file name in tar archive: "np-linear-0.1.1.1\\src\\Aux.hs". For portability, hackage requires that file names be valid on both Unix and Windows systems, and not refer outside of the tarball. ==== ✂ ==== The tarball is created by 'cabal sdist': cabal-install version 1.18.0.2 using version 1.18.1.1 of the Cabal library. I also installed the newest cabal-install, on another machine, but this did not help (same error). I also tried to create a tarball by hand, using 'tar --format=ustar', but this again resulted in the same error message. By the way, I'm on linux, not Windows, so it is not clear how the backslashes get in the file names. Wh
Categories: Offsite Discussion

Using newtype to "tag" values with a context

Haskell on Reddit - Mon, 06/16/2014 - 8:22am

I'm not really sure if this pattern has a name, but it occured to me a few days ago and I've just been thinking about this, but haven't really used it.

Say that you have a function magic which accepts a CreditCard type and does some magic with it. At that point you really expect the card to be already validated (which happens up in the call stack). But since the CreditCard type is just a value, it doesn't carry around the context having passed validation.

Just to make this clear, I'm not talking about simple string validation, but something like checking with a payment gateway and making a $0 transaction, to actually check that the card is valid. Think of this example as something you only want to validate once.

Now we've established that the magic function should never be called with a raw CreditCard that hasn't been through the validation, a program that does such thing shouldn't even compile, right?

The thing I came up with is to use a newtype wrapper, something like newtype Valid a = Valid a, so that I can then have the function type defined as magic :: Valid CreditCard -> IO ().

This way when I get a new CreditCard from a user or something, I can run it through a validation which would return either a Valid CreditCard, or some error. For example validate :: CreditCard -> Either ValidationError (Valid CreditCard).

What do you guys think about this? Do you do this? Does it make sense? Does it have a name?

submitted by progfu
[link] [9 comments]
Categories: Incoming News

MonadReactive, embedded monadic reactiveness

Haskell on Reddit - Mon, 06/16/2014 - 7:55am

Hi! Today I decided to present something I’ve been wandering around for some days now.

The initial problem is this:

Given a context with values, how could we react to a change in that context?

I came up with a very small solution, but that works well for me. Here’s a lpast link to my idea – I’ll make a package later if we find it cool and sexy.

The idea: you have two concepts: the monad you want to react to (m), and the monad you want to react in (r). When something happens in m, something should happen in r. We can state that m is observed by r. It’s then quite simple: my library provides a way to wrap monadic functions in the observed monad into the observer so that when such a function is called, the observer reacts.

I know FRP, and I know it’s great, but I wanted to present something way simpler, for not-that simpler problems.

What do you think folks? Should I make a monad-reactive package, or do you think it’s worthless?

submitted by _skp
[link] [13 comments]
Categories: Incoming News

BNFC-meta being maintained? Is there public src repo?

haskell-cafe - Mon, 06/16/2014 - 5:33am
Dear BNFC-meta developers and users, I've been using BNFC-meta for the parser of my experimental language Nax language implementation ( https://github.com/kyagrd/mininax ). It's very cool 'cause you don't need to write makefile or cabal entries to call the command line tools (bnfc, alex, happy), and you get quasiquoters for free, which really makes the early development pleasant. But due to the bug fixed in recent versions of BNFC, probably after latest BNFC-meta release, I'll have to switch back to using plain BNFC at some point. (FYI,the bug is that block comments arn't working). If there is a source repository that has ported more recent versions of BNFC into BNFC-meta, it'll be helpful for people like me. Or, if the source repository has open access and easy to participate (e.g., putting on github or something like that), we can draw community support maintaining BNFC-meta to keep up with the recent BNFC (and also happy and alex) versions. -- Ki Yung Ahn
Categories: Offsite Discussion

type families and type classes

haskell-cafe - Sun, 06/15/2014 - 11:25pm
Hi all, I have a bunch of data types which are "divided" in other data types as following: type FileName = String data FileWish = File FileName deriving (Show, Eq) data FileFact = FileExist | FileDontExist deriving (Show, Eq) data FileAction = FileCreate deriving (Show, Eq) observe :: FileWish -> [FileFact] observe :: undefined plan :: FileWish -> FileFact -> [FileAction] plan (File _) FileDontExist = [FileCreate] plan (File _) FileExist = [] perform :: FileWish -> [FileAction] -> IO () perform :: undefined I want to have a model as extensible as possible, even if I'm new to Haskell, I think that it's preferable to base parts of system on behavior (type classes) rather than data types. So I have File that give a Wish, a Fact (via observe) and a Action (via plan). I want to put observe, plan and perform in different type classes (let's say Observable, Plannable and Performable). When I create a new thing (like File) I want, fo
Categories: Offsite Discussion

What are the problems with instances for polymorphictypes?

haskell-cafe - Sun, 06/15/2014 - 8:47pm
In other words instances for forall-types, such as: instance Foo (forall a. [a]) where ... It feels obvious to me that there *would* be problems with this, but I'm curious about what, exactly, they are. Could someone familiar with the matter either elaborate on them, or refer me to an existing explanation, a previous discussion, or something of the sort? I *don't* have any kind of use case in mind, I'm merely seeking a better understanding of the type-system issues involved. (I attempted Google, but didn't have much success.) Thanks in advance. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Can't get satisfaction from tying knots

Haskell on Reddit - Sun, 06/15/2014 - 6:20pm

I'm currently working on language-gcl, a library that currently doesn't do much more than implement Dijkstra's guarded command language (GCL). GCL only defines two 'building blocks' of a programming language, because the manuscript it's defined in (EWD 418) focuses mostly on formal methods.

The building blocks of GCL are the alternative construct (if ... fi) and the repetitive construct (do ... od), which contain guarded commands. Dijkstra doesn't define the expression language (except that the guards must be decidable predicates) and explicitly leaves room for 'other statements'; he uses examples of (concurrent) assignment, e.g.:

if true -> x := Y; y := Y; do x > y -> x := x - y [] y > x -> x, y := y, x od fi

So anything if...fi or do...od is defined by GCL, but everything else (the guard expressions, the assignment statements) is up to whoever uses GCL.

So I decided to start with this:

data GCL stmt guard = Alternative [GC stmt guard] | Repetitive [GC stmt guard] | Statement stmt data GC stmt guard = GC guard [GCL stmt guard]

This allows for some extensibility, such as concurrent assignment, assert and assume statements, and many other things.

I ran into problems with the extensibility on two distinct occasions. One involved adding loop invariants (type parameter explosion!), but I believe that my current solution (adding a [guard] field to Repetitive) is reasonable.

The other is a little more problematic, which (initially) involves declaring variables. If I want to extend GCL with any constructs that may contain more GCL, I run into knot-tying problems. Ideally, I want to simply define something like this:

data Variables name ty expr = Declare [(name, ty)] gcl | Assign [(name, expr)]

-edit-

I could end this right here, with (gcl ~ GCL (MoreStmts name ty expr) expr), but this doesn't really sit right with me, DRY being one problem:

data Exceptions gcl = Raise | Rescue gcl gcl

It would also be really nice to be able to spice things up à la carte, e.g. GCL (Exceptions :+: Variables name ty expr) expr, but I would lose that by using this solution.

So, to tie the knot, I could make gcl the last type variable of MoreStmts and introduce the horrific nice auxiliary type

newtype GclKnot stmt1 guard = GclKnot (GCL (stmt1 (GclKnot stmt1 guard)) guard)

but I fear the doubling of type variables will get me into all sorts of trouble once I want to use these things with type classes. I can also forget about deriving any instances.

Does anyone have an idea for improvement? Or am I trying too hard?

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