# News aggregator

### Munich Haskell Meeting

### RV 2014: Call for Participation

### "Implementation and Abstraction in Mathematics": "The main result [is] an abstraction theorem stating that isomorphic objects are inter-substitutable in well-typed contexts" [abstract, link to PDF]

### Looking for improvements/suggestions for a simple Tictactoe game!

I am looking for any and all feedback on improving the organization or style of the code to make it more idiomatic (code).

The things I'm considering doing are

Making a dedicated Index type (instead of using Word) to constrain indices to only 3 values

Making Board a newtype

Removing StateT (I'm not exactly sure what benefits it brings other than making it explicit that there is state)

but I'm not sure if these are idiomatic either.

One question I have is why don't libraries use Word instead of Int when representing size or indices?

submitted by precalc[link] [5 comments]

### New Functional Programming Job Opportunities

### Hac φ (Philadelphia): Oct 17-19, 2014

### Awesome Machine Learning is missing Haskell libraries. BTW, what's the state of Haskell machine learning libraries compared to Julia ones? Is there a lot of development done?

### If-Then-Else Type Family

While designing a REST API client, I hit a problem where the data types I'm serializing to/from JSON differ only in a few fields for GET and POST requests. Rather than write two separate instances, I was wondering about using type families:

{-#LANGUAGE DataKinds #-} {-#LANGUAGE TypeFamilies #-} {-#LANGUAGE TypeOperators #-} module Main where data Method = GET | POST type family (m :: Method) := (n :: Method) :: Bool type instance GET := GET = True type instance GET := POST = False type instance POST := GET = False type instance POST := POST = True type family (b :: Bool) :? c :: * type instance True :? (x, y) = x type instance False :? (x, y) = y type x :. y = (x, y) data Resource (m :: Method) = Resource { param1 :: GET := m :? Int :. () , param2 :: POST := m :? Int :. () , param3 :: Int }This is still very much a sketch, but I was wondering if there are any other examples of if-then-else computations at the type level (or if this is even a good idea at all).

EDIT: Actually, I'm not sure how to get this to work. When I try

get :: Resource GET get = Resource 1 () 0I get the following type error:

Couldn't match type `()' with `(('POST := 'GET) :? Int, ())' Expected type: (('POST := 'GET) :? Int) :. () Actual type: () In the second argument of `Resource', namely `()' In the expression: Resource 1 () 0 In an equation for `get': get = Resource 1 () 0EDIT: Fixed with help from jozefg: http://lpaste.net/108310

submitted by markandrus[link] [9 comments]

### First-Class "Statements": IO as data

### Looking for Haskell Summer Course

I heard about a online summer school for the haskell programming language. AFAIK it is free. I just can't remember neither the name of the lecturer nor the course.

Does anybody know such a online cours/summer school for haskell this year or is able to give some hints?

Thanks in advance

Edit: Solved!

submitted by haskellsummer[link] [2 comments]

### What would your ideal Monad combiner API look like?

Both mtl and extensible-effects try to provide a simple, type-safe, performant way of combining two Monads into 1 to get the effects of both, but most would a agree that they fall flat in one area or another. My question is: What would the API of the perfect solution look like if issues like performance were ignored?

submitted by sccrstud92[link] [17 comments]

### Fusion of list functions

### Problem with existential type and instance.

### Building list of functions in parallel.

How do I go about building a list of functions in parallel? I have a bunch of entities that create a list of changes to be applied in sequence, but I want to generate the functions in parallel. Is there any easy way to force evaluation of all arguments required for a function? Does this have to be done on a case by case basis? What does a bang do in the following definition:

data Foo a b = Foo !(a -> b) submitted by Agitates[link] [5 comments]

### High(low) performance recursion

I have this recursive formula (Panjer recursion) that I need to implement efficiently in order to numerically approximate the probability distribution of the sum of iid random variables (I will now use Latex notation) :

s*{r}=(1-p)\cdot\sum{r}*{i=1}g*{i}\cdot s*{r-i}

I have implemented it in Haskell and Matlab but in both cases the code is too slow for (not so much) high 'r' due to the recursive nature of the problem.

I know that expressing recursive calls in terms of \textit{map} and \textit{fold} function would speed up the computation and make it even faster than a loop but I am stuck and I can not do better than this:

prob :: Int -> Float -> [Float] -> Float

prob r p gs = (1-p) * ( foldr (+) 0 [ g * ( prob (r-b) p gs) | (g,b) <- zip gs [1..r] ] )

Would you know how to improve it?

submitted by ceikit[link] [26 comments]

### PPDP 2014: Program and 2nd Call for Participation

### Exception in simple Pipes example

So I took the simple example of using Pipes to read from reddit (see here) and tried to turn it into a stand alone Producer.

It works but instead of just stopping when there's no more data coming in, it throws an exception. What am I missing?

{-# LANGUAGE OverloadedStrings #-} module Main where import Pipes as P import Pipes.HTTP import Pipes.ByteString as PB downloadRedditExample :: IO (Producer ByteString IO ()) downloadRedditExample = do req <- parseUrl "http://www.reddit.com/r/haskell.json" withManager defaultManagerSettings $ \m -> withHTTP req m (return . responseBody) main :: IO () main = do redditPipe <- downloadRedditExample runEffect $ redditPipe >-> PB.stdoutAlso on lpaste at http://lpaste.net/108221

submitted by hiptobecubic[link] [8 comments]