News aggregator

and / or

libraries list - Tue, 08/19/2014 - 7:24am
First question: how bad would it be to use the Prelude definitions of and and or? I assume if there's a problem it's probably excessive duplication by the inliner? Second question: if that would be bad, why not rewrite them to foldr forms, then write them back, like other things do? Statement: if the current arrangement really is the best, then we should add two additional rules: "and/augment" forall (g::forall b.(Bool->b->b)->b->b) (xs::[Bool]) . and (augment g xs) = g (&&) (and xs) "or/augment" forall (g::forall b.(Bool->b->b)->b->b) (xs::[Bool]) . or (augment g) = g (||) (or xs)
Categories: Offsite Discussion

Do you or how do you use object-based programming in Haskell?

Haskell on Reddit - Tue, 08/19/2014 - 1:41am

Should this topic be moved to /r/haskellquestions? Someone please help me! ಠ_____ಠ

To design bigger programs, or to solve more complicated problem, we usually divide them into smaller parts and solve them individually. And OBP or OOP are most famous design patterns.

Here comes the problem, how do we use something like OBP in Haskell?

[Edit] 19 Aug

Don't get me wrong. I'm saying object-based, not object-oriented. Object-oriented (not definitional) means everything is an object. I just want to use some object to pack things into a whole.

Although we are doing FP, we'll still have to be faced with the side effect things. Especially when in some realtime/long-term/interactive programs, there comes more side effects.

Two different implementation I find are

1) I call the following C++ style

module Something.Counter ( Counter, newCounter, counterIncrement, counterReset ) where -- hiding "counterNumber" as private member import xx data Counter = Counter { counterNumber :: IORef Int } newCounter :: IO Counter newCounter = return $ Counter (newIORef (0 :: Int))) counterIncrement :: Counter -> IO () counterIncrement counter = modifyIORef' (counterNumber counter) (+1) counterReset :: Counter -> IO () counterReset counter = writeIORef (counterNumber counter) 0

(2) I call the following JavaScript style (or closure style, maybe)

module Something.Counter where import xx data Counter = Counter { counterIncrement :: IO () counterReset :: IO () } newCounter :: IO Counter newCounter = do number <- newIORef (0 :: Int) let increment = modifyIORef' number (+1) let reset = writeIORef number 0 return Counter { counterIncrement = increment counterReset = reset }

(The latter may use more memory in some cases, but also easier to write sometime.)

(You may ask why I prefer to use this imperative style in such a simple Counter. This is just a example to make me better understood. For some real example, I would pick something like hash-table which is born non-funtional. )

But both implementation have the problem: you will need to write something like

counterIncrement counter

compare this with other imperative OOP languages


Think about this

dog.getLeg(1).getToe(2) dogLegToe (dogLeg dog 1) 2

The syntax will be complicated and names will get longer and longer (and you won't want to use TypeClass here).

So object-based programming in Haskell is not easy. How do you do the encapsulation? Did I get something wrong or do you NOT use OBP at all?

submitted by RnMss
[link] [56 comments]
Categories: Incoming News

Guard expression over a range, is it possible?

Haskell on Reddit - Tue, 08/19/2014 - 1:30am

Okay, so I have a list of Integers, which I want to convert into chars, however, it's not in ASCII, it's a custom mapping. Is it possible to say,

[convertChar x | x <- intsIn]

where convertChar is something like

convertChar :: Integer -> Maybe Char convertChar a | a isElementOf [0..25] = Just (chr (a + ord 'A')) | a isElementOf [26..51] = Just (chr (a - 26 + ord 'a')) | a isElementOf [52..61] = Just (chr (a - 52 + ord '0')) | a == 62 = Just '+' | a == 63 = Just '/' | otherwise = Nothing

yes that's base64

Also, should I be using Maybe's, or throwing Exceptions?

Also, will the compiler make the ranges staticly generated, or will it recreate them every function call?

(edit 14-08-19)_________________________________________________________________________

Okay, list membership function == elem So,

convertChar a | a `elem` [0..25] = Just (chr (a + ord 'A')) | a `elem` [26..51] = Just (chr (a - 26 + ord 'a')) | a `elem` [52..61] = Just (chr (a - 52 + ord '0')) | a == 62 = Just '+' | a == 63 = Just '/' | otherwise = Nothing

So that's Question 1 solved.

Oh, and

prettyPrintBase64 :: [Int] -> String prettyPrintBase64 intsIn = catMaybes [prettyPrintBase64Char c | c <- intsIn]

also, whoops, forgot the Just declarations...

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

Type-level numbers problem

haskell-cafe - Mon, 08/18/2014 - 8:15pm
Hi! I wrote one thing with type-level numbers that were represented as simple data Zero data Succ a Then, in order to not invent my own peano numbers, I decided to go look for ones, and found GHC.TypeLits. But unfortunately, it shows a weird error for me. Here is a piece of code: The one that's below "main" is working properly, while the one on top of it gives this error: typenats.hs:17:16: No instance for (Op D (0 + 1)) arising from a use of `f' Possible fix: add an instance declaration for (Op D (0 + 1)) In the expression: f (VJ i :: VJ D (0 + 1)) In an equation for `f': f (VJ i) = f (VJ i :: VJ D (0 + 1)) In the instance declaration for `Op D 0' Maybe I worked too much on type-level numbers today to not understand this simple error I'm getting, but could someone be so kind and explain me what am I doing wrong? Thank you very much! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Why is GHC Runtime Enviornment in C?

Haskell on Reddit - Mon, 08/18/2014 - 3:11pm

I have been using haskell for about half a year, and one question that bothered me is why isn't the runtime of GHC written in haskell?

It seems that the language is capable of handling this task, and some other languages do (Common Lisp being one). I understand that there are some limitations to this, and OS specific tasks need to be handle natively. However, the rest could be haskell and not the daunting 50,000 lines of C.

submitted by Artemis311
[link] [31 comments]
Categories: Incoming News

Functional Programming Group at the University of Kansas: Bluetooth on Haskell

Planet Haskell - Mon, 08/18/2014 - 3:04pm
I'm presenting a very early draft of my bluetooth library. As its name suggests, bluetooth is a Haskell frontend to low-level Bluetooth APIs, making it similar in spirit to Python's PyBluez and Java's BlueCove.
What it can doCurrently, bluetooth only supports Linux. It has the capability of running an RFCOMM server and client. Theoretically, it should also support L2CAP servers and clients, although this has not been tested yet.
What it will eventually doI plan to have bluetooth support each of the GHC Tier 1 platforms—that is, Windows, OS X, Linux, and FreeBSD. I want to have the capability to run the full gamut of L2CAP and RFCOMM-related functions on each OS, as well as any additional OS-specific functionality.
MotivationBluetooth programming on Haskell is currently in a very primitive state. As of now, there are only two packages on Hackage that make any mention of Bluetooth (as far as I can tell):

  1. network hints in its Network.Socket module that there is an AF_BLUETOOTH socket address family. However, trying to use it with network will fail, since there is no corresponding Bluetooth SockAddr.
  2. simple-bluetooth by Stephen Blackheath offers some of what my own bluetooth package offers (namely, RFCOMM client capability on Windows and Linux).
However, there is currently no comprehensive, cross-platform Haskell Bluetooth library à la PyBluez or BlueCove. I want bluetooth to fill that niche.
How bluetooth worksbluetooth can be thought of as a wrapper around network. After all, Bluetooth programming is socket-based, so Network.Socket already provides most of what one needs to implement a Bluetooth server or client. There are several gotchas with Bluetooth programming, however:
  • Every major OS has a completely different Bluetooth software stack. For example, Linux uses BlueZ, and Windows has several different stacks, including Winsock and Widcomm. Therefore, bluetooth is not likely to work identically on every OS.
  • Windows in particular is challenging to support since several Winsock functions do not work correctly on the version of MinGW-w64 that is currently shipped with GHC for Windows (only the 64-bit version, no less). For this reason, I probably won't develop a Windows version of bluetooth until this issue is resolved.
It is recommended that you have a basic understanding of Bluetooth programming before attempting to use bluetooth. I recommend this introduction by Albert Huang.
ExamplesThe following are abridged examples of the RFCOMM client and server examples from the bluetooth repo.
RFCOMM servermodule Main where
import Data.Set

import Network.Bluetooth
import Network.Socket

main :: IO ()
main = withSocketsDo $ do
let uuid = serviceClassToUUID SerialPort
proto = RFCOMM
settings = defaultSDPInfo {
sdpServiceName = Just "Roto-Rooter Data Router"
, sdpProviderName = Just "Roto-Rooter"
, sdpDescription = Just "An experimental plumbing router"
, sdpServiceClasses = singleton SerialPort
, sdpProfiles = singleton SerialPort

handshakeSock <- bluetoothSocket proto
btPort <- bluetoothBindAnyPort handshakeSock anyAddr
bluetoothListen handshakeSock 1
service <- registerSDPService uuid settings proto btPort
(connSock, connAddr) <- bluetoothAccept handshakeSock
putStrLn $ "Established connection with address " ++ show connAddr

message <- recv connSock 4096
putStrLn $ "Received message! [" ++ message ++ "]"
let response = reverse message
respBytes <- send connSock response
putStrLn $ "Sent response! " ++ show respBytes ++ " bytes."

close connSock
close handshakeSock
closeSDPService service
RFCOMM clientmodule Main where

import Network.Bluetooth
import Network.Socket

import System.IO

main :: IO ()
main = withSocketsDo $ do
let addr = read "12:34:56:78:90:00"
port = 1

sock <- bluetoothSocket RFCOMM
bluetoothConnect sock addr port
putStrLn "Established a connection!"

putStr "Please enter a message to send: "
hFlush stdout
message <- getLine

messBytes <- send sock message
response <- recv sock 4096
putStrLn $ "Received reponse! [" ++ reponse ++ "]"

close sock
<script type="text/javascript"> SyntaxHighlighter.highlight(); </script>
Categories: Offsite Blogs

Fully funded PhD position on Computational Logic/Functional Programming/Interactive Theorem Proving, University of Dundee, Scotland

haskell-cafe - Mon, 08/18/2014 - 9:45am
One fully funded PhD position on Computational Logic/Functional Programming/Interactive Theorem Proving is available at the University of Dundee, Scotland. For more information, please email katya< at > or refer to: The funding is provided by EPSRC Doctoral Training Partnership Scheme, and is available for UK residents only. Katya Ekaterina Komendantskaya Senior Lecturer, Head of PhD Studies Room 1.04, Queen Mother Building School of Computing, University of Dundee Scotland, DD14HN Tel: (+44) 01382384820 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

CUFP 2014: Call For Participation

General haskell list - Mon, 08/18/2014 - 9:16am
****************************************************************** CALL FOR PARTICIPATION Commercial Users of Functional Programming (CUFP) 2014 at ICFP 2014; Gothenburg, Sweden, Sep 4-6. ****************************************************************** Overview ======== Functional programming has been at the forefront of a new generation of programming technologies: Companies employing functional programming use it to enable more effective, robust, and flexible software development. The annual CUFP workshop is designed to serve the growing community of commercial users of functional programming: Practitioners meet and collaborate; language designers and users can share ideas about the future of their languages; experts share their expertise on practical functional programming. CUFP 2014 begins with two days of tutorials by top-notch language experts including advanced tutorials on special topics, followed by a day of talks about industrial applications of functional programming.
Categories: Incoming News

JP Moresmau: Fame at last!

Planet Haskell - Mon, 08/18/2014 - 9:10am
I was reading the book "Haskell Data Analysis Cookbook" when suddenly, my name pops up! Funny to see a link to a 7 year old blog entry, who knew I would go down in history for a few line of codes for a perceptron? It's deep in Chapter 7, for those interested. Maybe this is a sign that I should abandon everything else and spend my time on AI, since it's obviously where fame and riches abound! Right...

Categories: Offsite Blogs

Wish list for GHC API tooling support

haskell-cafe - Mon, 08/18/2014 - 9:06am
At the moment the GHC API is a sort of poor relation in the haskell world, where it could be a significantly useful resource for the growing list of haskell tool providers. Based on my experiences with HaRe, I have started putting together a wish list of features I would like to see in it, which is here I welcome feedback / discussion on this. Regards Alan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Unable to (Cabal) Install... Anything.

Haskell on Reddit - Mon, 08/18/2014 - 8:08am

I've been trying to set up Haskell with the Haskell Platform 2014 version on Windows, and I've been running into a brick wall. Whenever I try to cabal install... anything, I get the exact same error:

setup-Cabal- does not exist cabal.exe Error: some packages failed to install: ... (list of packages)

I've checked around my filesystem, and I found it in the directory, C:\Users\Crockeo\AppData\Roaming\cabal\setup-exe-cache\. I tried adding that to my %PATH%, but the same error still occurs.

Does anyone happen to know what's going on?

Thank you so much!

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

What do you do with huge numbers of dependencies?

Haskell on Reddit - Mon, 08/18/2014 - 3:04am

I'm working on a new Haskell codebase that has quickly accumulated the largest list of dependencies (30 stated in the .cabal file) that I've seen in any software project. This is of some concern because installing dependencies in Haskell tends to take a long time and it's not uncommon to have to start over.

Anyone have any experience with this? Does it end up having an impact for example when deploying code? How often do you split a component off into a separate project? Any other fun strategies?

submitted by scottansan
[link] [11 comments]
Categories: Incoming News

CUFP 2014: Call for Participation (Sept 4-6 alongside ICFP in Gothenburg)

Haskell on Reddit - Mon, 08/18/2014 - 2:35am


Commercial Users of Functional Programming (CUFP) 2014 at ICFP 2014;

Gothenburg, Sweden, Sep 4-6.


Functional programming has been at the forefront of a new generation of programming technologies: Companies employing functional programming use it to enable more effective, robust, and flexible software development.

The annual CUFP workshop is designed to serve the growing community of commercial users of functional programming: Practitioners meet and collaborate; language designers and users can share ideas about the future of their languages; experts share their expertise on practical functional programming.

CUFP 2014 begins with two days of tutorials by top-notch language experts including advanced tutorials on special topics, followed by a day of talks about industrial applications of functional programming.

More information about CUFP 2014 is available on the CUFP web site at

Registration is available at:


  • T1: Programming with Dependent Types, Ulf Norell

  • T2: Haskell in the Real World, Stefan Wehr

  • T3: Intro to Elm: a field guide for functional front-end programming (Part 1), Evan Czaplicki & Spiros Eliopoulos

  • T4: Elm-d3: Front-end Development without Frameworks (Part 2), Spiros Eliopoulos

  • T5: Idris: Practical Software Verification with Dependent Types, Edwin Brady

  • T6: Lens, Edward Kmett


  • T7: Introduction to OCaml, Leo White & Jeremy Yallop

  • T8: Programming in Rust, Felix Klock & Lars Bergstrom

  • T9: Tinkering with the Raspberry Pi using Erlang, Torben Hoffmann

  • T10: Hands-on Functional Web Development in F# with WebSharper, Adam Granicz

  • T11: Batteries Included: Generative Programming with Scala and LMS, Tiark Rompf & Nada Amin

  • T12: Introduction to testing with QuickCheck, John Hughes


  • Keynote: Making Money From FP, Joe Armstrong, Ericsson and Royal Institute of Technology in Stockholm

  • Functional Programming at Verizon OnCue, Timothy Perrett, Verizon

  • Adopting Functional Programming with OCaml at Bloomberg LP, Maxime Ransan, Bloomberg LP

  • MBrace: large-scale programming in F#, Eirik Tsarpalis, Nessos

  • Probabilistic Synchronization of State Between Independent Nodes, Erlend Hamberg

  • Towards "annex", a Fact Based Dependency System, Mark Hibberd

  • Building data and time-series analytics tools for F#, Tomas Petricek & Howard Mansell

  • Haskell in the Misson Control Domain, Michael Oswald

  • Haskell tools for satellite operations, Björn Buckwalter

  • F# For Fun and Games, Anthony Brown

  • Some usages of functional programming for FO and quants, Renaud Bechade

  • Reactive I/O with Scala, Akka, and Play, Kenneth Owens, Comcast

  • If your server is a function, is your company a library?, Andrew Cowie

submitted by edwardkmett
[link] [4 comments]
Categories: Incoming News

Tom Schrijvers: Algebraic Effect Handlers, Twice

Planet Haskell - Mon, 08/18/2014 - 2:05am
I have two new papers on algebraic effect handlers:

  • Effect Handlers in Scope
    Nicolas Wu, Tom Schrijvers, Ralf Hinze.
    To appear at the Haskell Symposium 2014.

    Algebraic effect handlers are a powerful means for describing effectful computations. They provide a lightweight and orthogonal technique to define and compose the syntax and semantics of different effects. The semantics is captured by handlers, which are functions that transform syntax trees.
    Unfortunately, the approach does not support syntax for scoping constructs, which arise in a number of scenarios. While handlers can be used to provide a limited form of scope, we demonstrate that this approach constrains the possible interactions of effects and rules out some desired semantics.
    This paper presents two different ways to capture scoped constructs in syntax, and shows how to achieve different semantics by reordering handlers. The first approach expresses scopes using the existing algebraic handlers framework, but has some limitations. The problem is fully solved in the second approach where we introduce higher-order syntax.
  • Heuristics Entwined with Handlers Combined
    Tom Schrijvers, Nicolas Wu, Benoit Desouter, Bart Demoen.
    To appear at the PPDP Symposium 2014.

    A long-standing problem in logic programming is how to cleanly separate logic and control. While solutions exist, they fall short in one of two ways: some are too intrusive, because they require significant changes to Prolog’s underlying implementation; others are lacking a clean semantic grounding. We resolve both of these issues in this paper.
    We derive a solution that is both lightweight and principled. We do so by starting from a functional specification of Prolog based on monads, and extend this with the effect handlers approach to capture the dynamic search tree as syntax. Effect handlers then express heuristics in terms of tree transformations. Moreover, we can declaratively express many heuristics as trees themselves that are combined with search problems using a generic entwining handler. Our solution is not restricted to a functional model: we show how to implement this technique as a library in Prolog by means of delimited continuations.
Categories: Offsite Blogs