News aggregator

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

CFP: CRV15 - 2nd Competition on Runtime Verification

General haskell list - Tue, 01/20/2015 - 9:29am
CRV 2015 The 2nd International Competition on Runtime Verification, held with RV 2015, September 22 – 25, 2015 Vienna, Austria CRV-2015 is the 2nd International Competition on Runtime Verification and is part of the 15th International Conference on Runtime Verification. The event will be held in September 2015, in Vienna, Austria. CRV-2015 will draw attention to the invaluable effort of software developers and researchers who contribute in this field by providing the community with new or updated tools, libraries and frameworks for the instrumentation and runtime verification of software. Runtime Verification is a verification technique for the analysis of software at execution-time based on extracting information from a running system and checking if the observed behaviors satisfy or violate the properties of interest. During the last decade, many important tools and techniques have been developed and successfully employed. However, there is a pressing need to compare such tools and techniques, since
Categories: Incoming News

ghc-7.10.0 type inference regression when faking injective type families

glasgow-user - Tue, 01/20/2015 - 7:29am
Hello List, With ghc - 7.8 and 7.6 the following program is accepted: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} class (UnF (F a) ~ a, Show a) => C a where type F a f :: F a -> a type family UnF a g :: forall a. C a => a -> String g _ = show a where a = f (undefined :: F a) -- :: a ghc- does not accept the program unless I uncomment the type signature (a :: a). I believe this is the main difference that prevents HList from compiling with 7.10, but I could have made a mistake in coming up with this minimal example. Regards, Adam
Categories: Offsite Discussion

Help with identity functor print instance and monadtransformers

haskell-cafe - Tue, 01/20/2015 - 7:09am
I understand the error below, but I'm not really sure what an instance of liftIO would look like for the Identity functor. I guess I'm not all to clear on what an identity functor is. I'm a little fuzzy on what an identity monad is. I understand that id gives the identity of something back pretty well though. Can anyone help? If anyone could help me fix the code below as well as explain the questions I have above it would be a great help. import Control.Monad.Trans.State import Control.Monad.IO.Class type MyState = State Int modAndPrintState :: Int -> MyState () modAndPrintState x = do get >>= \i -> do liftIO . print $ i if even x then put (x + i) else put (i * (x + 1) - x) main = undefined
Categories: Offsite Discussion

Package version question with Cabal

glasgow-user - Tue, 01/20/2015 - 6:14am
Hi! I've uploaded my library to Hackage, and now I'm trying to install it via cabal: ~/src/hsshellscript $ cabal install Resolving dependencies... In order, the following will be installed: hsshellscript-3.3.3 (reinstall) Warning: Note that reinstalls are always dangerous. Continuing anyway... Configuring hsshellscript-3.3.3... Building hsshellscript-3.3.3... Preprocessing library hsshellscript-3.3.3... In-place registering hsshellscript-3.3.3... Creating package registration file: /tmp/pkgConf-hsshellscript-3.37397.3 Installing library in /home/v/.cabal/lib/x86_64-linux-ghc-7.8.3/hsshellscript-3.3.3 Registering hsshellscript-3.3.3... Installed hsshellscript-3.3.3 ~/src/hsshellscript $ cabal list hsshellscript * hsshellscript Synopsis: Haskell for Unix shell scripting tasks Default available version: 3.3.2 Installed versions: 3.3.1, 3.3.2, 3.3.3 Homepage: License: LGPL The thing wich looks like a problem is, that the new version isn't made t
Categories: Offsite Discussion

ghc 7.8.4 fedora

Haskell on Reddit - Tue, 01/20/2015 - 1:16am

[Solved]I got it now sudo yum remove ghc* sudo yum autoremove sudo yum-config-manager --add-repo sudo yum install ghc-7.8.4

submitted by hornysama
[link] [22 comments]
Categories: Incoming News