News aggregator

Getting Into Netwire

Haskell on Reddit - Sun, 03/15/2015 - 5:32am
Categories: Incoming News

chat #haskell

Haskell on Reddit - Sun, 03/15/2015 - 5:05am
Categories: Incoming News

Wrong .hsc file paths on Windows

haskell-cafe - Sat, 03/14/2015 - 9:08pm
Hello, I was trying to port some of my code to Windows. I've installed GHC with MinGHC ( Unfortunately some packages, namely zlib and network, won't install, with the same error: getModificationTime cannot locate a file like CodecCompressionZlibStream.hsc or NetworkSocketTypes.hsc. With zlib, I figured out I just need to change mentions of "Codec/Compression/(...)" adding two slashes instead of one. Now with network I'm stuck, I can't find where the path was set at all. Is there some step I should have done prior to installation that would get the paths right? Best regards, Marcin Mrotek
Categories: Offsite Discussion

Language extensions

Haskell on Reddit - Sat, 03/14/2015 - 3:26pm

One thing I am having a little trouble understanding is the number of language extensions in Haskell. Lens requires templates. Then there is OverloadedStrings. Is there any source that can explain the different extensions out there, what they do, and whether they are "OK" to use? Is there a reason that these extensions have not been merged into Haskell?

submitted by tempforfather
[link] [39 comments]
Categories: Incoming News

Why are ADTs necessary?

Haskell on Reddit - Sat, 03/14/2015 - 1:04pm

As I understand it, GHC Haskell compiles a lot of constructs out, ending up with a very simple language, Core. For example, typeclasses are compiled out, and the dictionaries are passed around explicitly.

I was wondering why Algebraic Data Types are not also compiled out. This would make Core simpler. An ADT like

data X = X1 Int | X2 Bool Int

could be represented as this type:

(Int -> r) -> (Bool -> Int -> r) -> r

and then pattern matching could be compiled to function application.

The two things that occur to me, as possible reasons why this is not done, are the resulting types being recursive, and possible difficulties with optimization.

The List type, for instance, would have to turn into a function with this type:

type List a = r -> (a -> List a -> r) -> r

This is a recursive type, and isn't allowed in Haskell; but recursive types aren't intractable or anything, they are supported in ocaml with the -rectypes flag.

The second issue is optimization: Just 5 can be stored and accessed as a very simple binary representation, something like {0x0001, 0x0005}. The equivalent without ADTs, (\f g -> g 5), would probably have a more complicated representation, unless special optimizations were applied to these kinds of expressions.

Is one of these issues the main reason that ADTs are kept even at the Core level? Or is it something else?

submitted by jpriestley
[link] [39 comments]
Categories: Incoming News


haskell-cafe - Sat, 03/14/2015 - 11:23am
Happy super pi day everybody! Henk-Jan van Tuyl
Categories: Offsite Discussion

Limit type variables to exclude function types?

Haskell on Reddit - Sat, 03/14/2015 - 10:07am

During some design thoughts for a small templating engine I recently had some ideas about automatically composing functions returning a Monoid with values of that Monoid into some sort of function taking all the parameters required by any of the functions (possibly eliminating duplicates if we ensure that every parameter type occurs only once).

So if we wanted to write an email to a person

data Person = Person { personFirstName :: Text , personLastName :: Text , personGender :: Gender } genderTitle :: Gender -> Text genderTitle Male = "Mister" genderTitle Female = "Ms"

about an event

data Event = Event { eventName :: Text , eventLocation :: Text }

instead of writing something ugly like

emailTemplate :: Person -> Event -> Text emailTemplate person event = concat [ "Hello " , genderTitle $ personGender person, " " , personFirstName person, " " , personLastName person, "\n\n" , "Want to come to ", eventName event, " at " , eventLocation event, "?" ]

we could write something more like

emailTemplate :: Person -> Event -> Text emailTemplate = "Hello " <++> genderTitle . personGender <++> " " <++> personFirstName <++> " " <++> personLastName <++> "\n\n" <++> "Want to come to " <++> eventName <++> " at " <++> eventLocation <++> "?"

where <++> is the operator I am having trouble implementing. I know that in this particular example NameFieldPuns or RecordWildCards would solve my problem mostly but the whole example is mostly to motivate the idea.

Basically the semantics of the <++> operator should be that it should work like Monoid's <> on values that are not a function type. On composing a function with a value it should return a function with the same parameters and compose the result of the input function when called with those parameters with the input value.

When composing two functions however it should essentially merge their parameter lists. This shouldn't be too hard by iterating over the parameter lists of the two functions but here I am running into problems because I haven't found a way to limit a type variable in Haskell to a non-function type.

Apparently I can limit a type variable to a function type like this

foo :: (a ~ (b -> c)) => a -> a foo = id bar = foo (1 :: Int) quux = foo (+1)

Here bar gives me a compile error as expected

FunctionVariableTest.hs:8:12: Couldn't match expected type ‘b -> c’ with actual type ‘Int’ Relevant bindings include bar :: b -> c (bound at FunctionVariableTest.hs:8:1) In the first argument of ‘foo’, namely ‘(1 :: Int)’ In the expression: foo (1 :: Int) In an equation for ‘bar’: bar = foo (1 :: Int)

However I haven't managed to do the opposite, limit it to a value that is not a function.

Is there a way to achieve this in current GHC/Haskell?

submitted by Taladar
[link] [16 comments]
Categories: Incoming News

repa parallelization results

haskell-cafe - Fri, 03/13/2015 - 6:23pm so i am seeing basically results with N4 that are as good as using sequential computation on my macbook for the matrix multiply algorithm. any idea why? Thanks, Anatoly
Categories: Offsite Discussion

Generalizing map?

libraries list - Fri, 03/13/2015 - 10:32am
A dozen of functions like concat, foldr, mapM, have been generalized through BBP. Then, why do we leave `map` just for lists? Obviously `map` can be generalized, so map :: Functor f => (a -> b) -> f a -> f b map = fmap The current definition of `map` looks too special to be a special case of mapM (map f = runIdentity . mapM (Identity . f)). _______________________________________________ Libraries mailing list Libraries< at >
Categories: Offsite Discussion

Proposal: Export cycleN from Data.Sequence

libraries list - Wed, 03/11/2015 - 4:14pm
Yesterday I rewrote `*>` for Data.Sequence (again), using an internal function cycleN :: Int -> Seq a -> Seq a The name of the function is based on that of Data.Sequence.iterateN. cycleN takes a sequence and cycles it as many times as requested: cycleN 0 $ fromList [1,2] = [] cycleN 5 $ fromList [1,2] = [1,2,1,2,1,2,1,2,1,2] The function is written to maximize sharing in the result sequence and to minimize construction time. Specifically, cycleN n xs should take something like O(|xs| + log n) space (of which all but O(log |xs| + log n) is shared with the structure of xs) and O(log |xs| + log n) time. With current (on GitHub) Data.Sequence exports, the only way to get this functionality with these time and space bounds is to combine replicate with *> : cycleN n xs = replicate n () *> xs This strikes me as a bit unpleasant. David
Categories: Offsite Discussion

-staticlib flag for building standalone static libraries producing very large libraries

glasgow-user - Sat, 03/07/2015 - 1:18pm
Hi all, Can anyone explain the following problem I'm having? I'm currently writing a game in Haskell. When I produce a plain old executable (for local testing) it's about 23M. However, when I create a static lib using the -staticlib flag it is 54M. Why the discrepancy? Sean _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users< at >
Categories: Offsite Discussion

New gtk2hs 0.12.4 release

gtk2hs - Wed, 11/21/2012 - 12:56pm

Thanks to John Lato and Duncan Coutts for the latest bugfix release! The latest packages should be buildable on GHC 7.6, and the cairo package should behave a bit nicer in ghci on Windows. Thanks to all!


Categories: Incoming News