News aggregator

TH not compiling when writing the code directly does

haskell-cafe - Thu, 03/12/2015 - 7:07am
I’m stuck getting a TH expansion to compile. When I take the generated code and compile it directly, it is fine. But when expanding and compiling, it fails. The problem seems related to instanceD, where I provide the type as: (appT (appT (conT devName') (varT $ mkName "Word8")) (varT $ mkName "BV”)) which expands to: IDENTIFICATION__MODEL_ID Word8 BV No matter what I put for the second type (BV), it generates the compile error. For example, Word8 or Word16 gives the same error. But if I take the resulting expression and just put it into the file and compile, it compiles fine. So something about expansion is causing the problem. Is there some more correct way to make the expression rather than nesting two appT? Any ideas? Note: the generation of the functions with (map (\f -> returnQ f) (concat funs)) is ugly in my opinion. I could not find the right way to express this. So all ideas welcome. Mike GEN DEC -------------- makeInstance :: String -> [String] -> Q [Dec] makeInstance devName regNam
Categories: Offsite Discussion

David Turner quote on lisp and FP

haskell-cafe - Thu, 03/12/2015 - 5:57am
There is this quote: *It needs to be said very firmly that LISP is not a functional language at all. My suspicion is that the success of Lisp set back the development of a properly functional style of programming by at least ten years.* David Turner found here and there on the net eg Does anyone have/know the original reference? Thanks Rusi
Categories: Offsite Discussion

Needs some help walking out of HarmTrace's Cabal Hell

Haskell on Reddit - Thu, 03/12/2015 - 1:35am

Hey r/haskell, so I got introduced to haskell a couple weeks ago trying to use a really cool music analysis hackage chordify is using. I love the language, but didn't expect cabal hell would be this bad. If anyone could help me figure out how to get HarmTrace's dependency resolved, I would be eternally thankful.


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

Mathematical functions with multiple arguments

haskell-cafe - Wed, 03/11/2015 - 10:45pm
Hi everybody, I have a function of type plot :: ([Double] -> Double) -- A function to plot -> [(Double, Double)] -- Range for all arguments -> IO () I want to enforce the fact that ranges for all arguments should be provided. Is there a way to make the type system enforce it?
Categories: Offsite Discussion

My first big Haskell project

Haskell on Reddit - Wed, 03/11/2015 - 8:54pm

Hey guys,

I was just looking back at my first big Haskell project, which you can find here:

It's a small "A.I." which creates music through a genetic algorithms. I put a couple of the tunes it made at various points online at ( plus one now as a "restart", be careful of your years on the earliest ones!).

Looking back on this code, it's a bit embarrassing now, so I was wondering, what have you guys learnt looking back at your first big projects?

submitted by julek1024
[link] [17 comments]
Categories: Incoming News

What imperative languages do Haskellers like?

Haskell on Reddit - Wed, 03/11/2015 - 6:24pm

Now that I've been using Haskell for almost a year I find going back to imperative languages incredibly frustrating. I went and brushed up on my Python and the biggest problem I had with it was how verbose it is (which frustrated me more than the lack of compile time optimisation or type safety...).

For various reasons I'm finding JavaScript to be quite nice. The syntax is reasonably lean, there are higher order functions and I can take lessons from Haskell about mutable state. Duck Typing is annoying, as is the lack of compile time assurance and the largely poor performance. I certainly wouldn't do anything more than client side functionality for web.

I realise that what I'm really liking about Haskell more than anything is how terse it is. Once you understand the syntax it's not just quick to write but it's easy to understand.

I've seen a bit of J around and it looks like it might push that a bit far. Anyone have any experience with it? Once you understand the syntax is it possible to decipher what someone else's code means or is it a "write only language"?

What imperative languages do Haskellers out there like?

submitted by TheCriticalSkeptic
[link] [84 comments]
Categories: Incoming News

References on haskellwiki

haskell-cafe - Wed, 03/11/2015 - 5:21pm
Hi, I've begun to do some formatting on old Monad Readers editions on Haskell Wiki. Unfortunately, there is no support for proper references support. Can the admin add the "Cite" extension ? It would help a lot. Thanks
Categories: Offsite Discussion

Arrows, Profunctors, DeepArrow, circat, GArrows, Lambda-CCC and more!

Haskell on Reddit - Wed, 03/11/2015 - 4:30pm

Fellow archers, (haha),

I've been working with Arrows and their various formulations recently. In particular, I've created a quasiquoter ArrowInit for proc-do notation that allows me to implement the CCA package without a pre-processor by de-sugaring the proc/do and then lifting functions appropriately. I am interested in a more generic endeavor to use a similar quasi-quoter to take arbitrary notation, and optimize/normalize while degrading gracefully. The more restrictive DeepArrow/circat/GArrow/Profunctor's allow for optimizations. My idea would be for a quasiquoter to detect which variant is possible for a particular expression, and then to instantiate for that restricted version.

There seems to be a constant low-level history of this sort of effort regarding Arrows, and I think the key is to expose the nice features of proc-do notation into these efforts. If this works, someone can draw out something like:

runItA = runConcurrently [arrow| proc (a,b) -> y <- getURL -< a z <- getURL -< b return (y,z) |]

and obtain the equivalent of using (<*> or ***) where

runItV = [arrow| proc n -> a <- A -< n y <- B -< a z <- C -< a return (y,z) |]

would be something like: A >>> (B &&& C) but be in a restricted arrow (note no use of arr, and all right hand side expressions are unchanged variables, no arbitrary functions needed). This allows users to define optimized versions of <*>, ***, &&& and so on that they get to use a comfortable proc notation with a range of abstractions.

Which of the restricted Arrow approaches would be ideal, and what sort of direction should an effort like this go in? Some similar approaches seem to have died out and I'd like to avoid that fate. Is there a particular effort I should join efforts with? Any direction/advice would be appreciated.

In a sense, this is similar to the ApplicativeDo proposal, but a step in between Applicative and Monad. ApplicativeDo notices when an expression can become an applicative, "ArrowDo" may notice when an expression can become an arrow-like expression.

-- (syntax is a bit off, but the idea should be clear) runItC n = do a <- A -< n b <- B -< a C -< (a,b)

This has no Applicative expression due to the reuse of a, but it can be an Arrow A >>> (returnA &&& B) >>> C instead of a monad. It can also be a 'restricted Arrow' due to a lack of arbitrary expressions, only tupling rearrangement.

runItD n = do Just a <- A -< n+1 b <- B -< a+2 d <- D -< a+3 C -< (a,b+d)

This variant should look something like: arr (\n->n+1) >>> A >>> arr (\(Just a)->(a,(a+2,a+3))) >>> second ( B *** D >>> arr (\(b,d) -> b+d)) >>> C )

I think all this should be possible. Worthwhile? Needed? I'm not sure, but I'm willing to give it a shot. It also connects various abstractions cleanly into a single framework. So far I've been able to implement the ArrowInit variant of this scheme.

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

Where is Haskell Weekly News syndicated?

haskell-cafe - Wed, 03/11/2015 - 4:25pm
Haskell Weekly News used to be syndicated on and sequence only has HWN up to March 2010, while contemplatecode goes up to the beginning of February. Is there any way that I can subscribe to HWN (preferably as RSS/Atom), and not other stuff that doesn't interest me? -- View this message in context: Sent from the Haskell - Haskell-Cafe mailing list archive 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

"let" inside "do" & scope

Haskell on Reddit - Wed, 03/11/2015 - 3:44pm

I tried this in GHC:

main = do let a = 2 print a let a = a+1 print a

It prints "2" and hangs. But "let" is supposed to create a new scope, right? The "a" on the left-hand side of "a = a+1" and the "a" on the right-hand side are different, so why the (apparent) infinite recursion?

I'm told that the above is just a sugared version of the following:

main = (\a -> (print a >> ((\a -> print a) (a+1)))) 2

And this works fine. It prints "2", then "3", and then quits.

So why doesn't the first one do the same thing?

submitted by ggchappell
[link] [19 comments]
Categories: Incoming News - Wed, 03/11/2015 - 1:49pm
Categories: Offsite Blogs