News aggregator

Why are record field lenses the opposite of every other lens?

Haskell on Reddit - Wed, 01/21/2015 - 4:34am

After getting into lenses a bit one thing stuck out for me [1]: all the "built-in" lenses seem to start with _ (e.g. _1, _2, _left, etc.) but with records this is exactly reversed: the actual field starts with _ but its lens does not.

Is there any reason for this? Is it under consideration to flip this for consistency?

[1] I don't like the _ convention and would have preferred something like putting an L at the end, but it's probably far too prolific to think about now. Regardless, whatever the convention is, it would be nice if it were completely consistent.

submitted by nicheComicsProject
[link] [7 comments]
Categories: Incoming News - Wed, 01/21/2015 - 1:21am
Categories: Offsite Blogs - Wed, 01/21/2015 - 1:21am
Categories: Offsite Blogs

Question about understanding type inference rules.

Haskell on Reddit - Wed, 01/21/2015 - 12:28am

I've been rereading about type inference rules lately and on thing that has always puzzled me is the difference between an implication symbol and a comma when describing a type context Gamma. For example in some cases a rule will say:

Gamma ⊢ x : T

This makes sense as the context gamma implies x has type T. But in some cases you will see, for example:

Gamma, y : S ⊢ x : T Which I understand to mean that the context Gamma with the added assumption y has type S implies x has type T. My question is why not say: Gamma ⊢ x : T, y : S

Is it because the assumption for y is being provided by the rule, meaning S is a new type variable?


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

Kevin Reid (kpreid): A Visual Introduction to DSP for SDR — now live in your browser!

Planet Haskell - Tue, 01/20/2015 - 10:51pm

My interactive presentation on digital signal processing (previous post with video) is now available on the web, at! More details, source code, etc. at the site.

(P.S. I'll also be at the next meetup, which is tomorrow, January 21, but I don’t have another talk planned. (Why yes, I did procrastinate getting this site set up until a convenient semi-deadline.))

Categories: Offsite Blogs

Unit test that a particular expression *does not* compile?

Haskell on Reddit - Tue, 01/20/2015 - 9:27pm

I just came across this D library that does compile-time unit checking similar to units or dimensional. However, if you look at the test cases on that page, there are tests that actually check whether certain sub-expressions compile:

// Dimensional correctness is check at compile-time unittest { Mass mass; static assert(!__traits(compiles, mass = 15 * meter)); static assert(!__traits(compiles, mass = 1.2)); }

Instead of just testing desired behaviour, this explicitly makes sure that bad behaviour is disallowed at compile-time.

Is this something we could implement in Haskell, possibly using TH? It seems like a good idea for libraries which intend to expose a typesafe API, and verify that bad behaviour is illegal at compile-time.

submitted by theonlycosmonaut
[link] [7 comments]
Categories: Incoming News

Why does that work but not this?

Haskell on Reddit - Tue, 01/20/2015 - 8:36pm

[x/4 | x <-- [0..100], x mod 4 == 0]

doesn't work

but this

[x*4 | x <-- [0..100], x mod 4 == 0]

works. Why?

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

"Found hole"

glasgow-user - Tue, 01/20/2015 - 8:36pm
Hello! What is a "hole"? This program fails to compile: main = _exit 0 I get this error message: ex.hs:1:8: Found hole ‘_exit’ with type: t Where: ‘t’ is a rigid type variable bound by the inferred type of main :: t at ex.hs:1:1 Relevant bindings include main :: t (bound at ex.hs:1:1) In the expression: _exit In an equation for ‘main’: main = _exit When I replace "_exit" with "foo", it produces a "not in scope" error, as expected. What is special about "_exit"? It doesn't occur in the Haskell Hierarchical Libraries. Bye Volker _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users< at >
Categories: Offsite Discussion

Robin KAY: HsQML released: Control those Contexts

Planet Haskell - Tue, 01/20/2015 - 5:17pm
Happy New Year! Another year and another new release of HsQML is out, the Haskell binding to the Qt Quick framework that's kind to your skin. As usual, it's available for download from Hackage and immediate use adding a graphical user-interface to your favourite Haskell program.

The major new feature in this release is the addition of the OpenGLContextControl QML item to the HsQML.Canvas module. Previously, the OpenGL canvas support introduced in left programs at the mercy of Qt to configure the context on their behalf and there was no way to influence this process. That was a problem if you want to use the latest OpenGL features because they require you to obtain a newfangled Core profile context whereas Qt appears to default to the Compatibility profile (or just plain OpenGL 2.x if that's all you have).

To use it, simply place an OpenGLContextControl item in your QML document inside the window you want to control and set the properties to the desired values. For example, the following snippet of code would request the system provide it with a context supporting at least the OpenGL 4.1 Core profile:

import HsQML.Canvas 1.0

OpenGLContextControl {
    majorVersion: 4;
    minorVersion: 1;
    contextType: OpenGLContextControl.OpenGL;
    contextProfile: OpenGLContextControl.CoreProfile;
The supported properties are all detailed in the Haddock documentation for the Canvas module. There's also a more sophisticated example in the corresponding new release of the hsqml-demo-samples package. This example, hsqml-opengl2, displays the current context settings and allows you to experiment with requesting different values.

This graphics chip-set has seen better days.
Also new in this release, i) the defSignalNamedParams function allows you to give names to your signal parameters and ii) the EngineConfig record has been extended to allow setting additional search paths for QML modules and native plugins..

The first point is an interesting one because, harking back, my old blog post on the Connections item, doesn't actually demonstrate passing parameters to the signal handler and that's because you couldn't ordinarily. You could connect a function to the signal manually using the connect() method in QML code and access arguments positionally that way, or written the handler to index into the arguments array for it's parameters if you were willing to stoop that low. Now, you can give the parameters names and they will automatically be available in the handler's scope.

Finally, the Template Haskell shims inside Setup.hs have been extended to support the latest version of the Cabal API shipping with version 1.22. The Template-free SetupNoTH.hs remains supporting 1.18 ≤ n < 1.22 will continue to do so at least until Debian upgrades their Cabal package. Setup.hs will now try to set QT_SELECT if you're running a recent enough version of GHC to support setting environment variables and this can prevent some problems with qtchooser(1).

release- - 2015.01.20

  * Added support for Cabal 1.22 API.
  * Added facility for controlling the OpenGL context.
  * Added defSignal variant with ability to set parameter names.
  * Added option for setting the module and plugin search paths.
  * Changed Setup script to set QT_SELECT (base >= 4.7).
  * Fixed crash resizing canvas in Inline mode.
  * Fixed leaking stable pointers when objects are collected.
  * Fixed Canvas delegate marshaller to fail on invalid values.
  * Fixed discrepancy between kinds of type conversion.
Categories: Offsite Blogs

New Student to Haskell

Haskell on Reddit - Tue, 01/20/2015 - 3:25pm

Hey guys,

First off, I've never posted on here before, so I hope I'm doing this correctly.

Anyways I was wondering how I, as a new student, can expand my knowledge/familiarity with what haskell can be used for in the real world. My haskell class that I'm taking is kinda slow for me and my experience with coding, so I want to get a head start with some personal projects. Unfortunately, I'm not sure where to find exercises/projects that I can solve with haskell on my own, and I was hoping someone could point me in the right direction.

Basically, I'm asking what small project can I create using Haskell? A video game? A database? Something on a website?

I don't know much about Haskell, or functional programming, since I am mostly familiar with object oriented Java and Python, so again, not sure what to pursue to fully understand this aspect of the programming language.

I know I can read books and articles and such but for me and many other programmers I know, the best way to learn is to program in the language itself.

So again, I'm looking for what I can pursue as a small project to help me get ahead with familiarity with the language.

Any references or examples to get started would be much appreciated.

Thanks! -President

submitted by Clown_For_President
[link] [20 comments]
Categories: Incoming News

Philip Wadler: Democracy vs the 1%

Planet Haskell - Tue, 01/20/2015 - 2:37pm

To celebrate the 750th anniversary of the first meeting of the British parliament, the BBC Today programme sponsored a special edition of The Public Philosopher, asking the question Why Democracy? The programme spent much time wondering why folk felt disenfranchised but spent barely two minutes on the question of how wealth distorts politics. (Three cheers to Shirley Williams for raising the issue.) An odd contrast, if you compare it to yesterday's story that the wealthiest 1% now own as much as the other 99% combined; or to Lawrence Lessig's Mayday campaign to stop politicians slanting their votes to what will help fund their reelection; or to Thomas Picketty's analysis of why the wealthy inevitably get wealthier. (tl;dr: "Piketty's thesis has been shorthanded as r > g: that the rate of return on capital today -- and through most of history -- has been higher than general economic growth. This means that simply having money is the best way to get more money.")
Categories: Offsite Blogs


haskell-cafe - Tue, 01/20/2015 - 2:33pm
Hi! I'm working with a lot of HashMap's and it's very frustrating how many times I've "lost" my data because of usage of either a Monoid instance of a HashMap (which is defined as H.union, which, upon collision, takes value from first hm and discards from second), or just using fromList in the wrong place. Whereas the data I'm working is is mostly defined as (Monoid v => HashMap k v), so what I need "by default" is actually something like `H.unionWith (<>)`. What I was wondering is this: is something like MonoidHashMap is desired to be in unordered-containers, or is this use-case only popular in my programs? I'm asking because I have a feeling that this thing might be useful quite a lot for others also. If not -- sorry for bothering :) Cheers! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Perform simple IO in Haskeline, inside InputT monad, without having to resort to unsafePerformIO

Haskell on Reddit - Tue, 01/20/2015 - 1:23pm

Given the proof of concept code below I'd like to be able to somehow perform my foo function with the ability to output the string Paul! and the possibility of getting its return value inside the InputT monad-transformer without using unsafePerformIO to remove the IO wrapper after runExceptT.

import Control.Monad.Except import System.IO.Unsafe (unsafePerformIO) import System.Console.Haskeline type ErrorWithIO = ExceptT String IO foo :: String -> ErrorWithIO String foo "paul" = do liftIO $ putStrLn "Paul!" return "OK!" foo _ = throwError "ERROR!" runRepl :: IO () runRepl = runInputT defaultSettings $ loop loop :: InputT IO () loop = do line <- getInputLine "> " case line of Nothing -> return () Just input -> do return $ putStrLn "asd" case unsafePerformIO $ runExceptT $ foo input of Left err -> outputStrLn err >> loop Right res -> do x <- outputStrLn . show $ res loop main :: IO () main = runRepl >> putStrLn "Goodbye!"

Am I missing something obvious here?

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

GHC 7.10 regression when using foldr

glasgow-user - Tue, 01/20/2015 - 1:20pm
I just discovered that the following program compiled fine using GHC 7.8.4 but was rejected by GHC 7.10.1-rc1: ~~~ data List a = Nil | Cons a (List a) instance Read a => Read (List a) where readsPrec d s = map convert (readsPrec d s) where convert (xs, s2) = (foldr Cons Nil xs, s2) ~~~ GHC 7.10 now complains: ~~~ Read.hs:5:23: Could not deduce (Foldable t0) arising from a use of ‘convert’ from the context (Read a) bound by the instance declaration at Read.hs:4:10-32 The type variable ‘t0’ is ambiguous Note: there are several potential instances: instance Foldable (Either a) -- Defined in ‘Data.Foldable’ instance Foldable Data.Proxy.Proxy -- Defined in ‘Data.Foldable’ instance GHC.Arr.Ix i => Foldable (GHC.Arr.Array i) -- Defined in ‘Data.Foldable’ three others In the first argument of ‘map’, namely ‘convert’ In the expression: map convert (readsPrec d s) In an equation for ‘readsPrec’:
Categories: Offsite Discussion

pdf - Tue, 01/20/2015 - 12:52pm
Categories: Offsite Blogs

Haskell - Tue, 01/20/2015 - 12:51pm
Categories: Offsite Blogs