News aggregator

Elm's |> operator

Haskell on Reddit - Tue, 09/29/2015 - 6:57am

I've been using Elm lately, and have fallen in love with the |> operator. For example:

totalPoints entries = entries |> List.filter .wasSpoken |> .points |> List.sum

I'm thinking of using it my Haskell code. Is it defined anywhere? I can't find anything on hoogle. If not, where should it be defined? It seems as basic as $ to me, suggesting it belongs in something like the prelude, but obviously it's not going to end up there any time soon. Is there a package of common extras or something somewhere that would accept a PR?

submitted by el-seed
[link] [58 comments]
Categories: Incoming News

Seeking a Haskell Mentor

Haskell on Reddit - Tue, 09/29/2015 - 6:18am

Hi, my name is Sean. I'm an independent contract developer out of Salt Lake City and run the Haskell meetup here.

I occasionally mentor people as they get started in programming. It's pretty casual, but the main thing I do is meet up with them every once in a while and review their progress. I look at what they've been doing and suggest what they should learn and do next. This doesn't take much of my time, while it accelerates their learning by a large factor.

I'm looking for someone who can do that for me with Haskell. I've been learning off and on for about 3 years, and in the last 8 months have really started using it professionally. At my skill level I can write a web application with Servant that talks to a database, including a custom newtype'd transformer stack. I wrote an extra combinator for Servant but didn't really understand what I was doing.

Is there anyone interested in mentoring me? I would be willing to pay for it if needed. Ideally we could do a hangout every so often, review some of my code and work, and get a recommendation on something to go learn or work on next.

Also I'd be happy to mentor someone less experienced than me to pay it forward.


submitted by el-seed
[link] [31 comments]
Categories: Incoming News

Can 64 bit bitboards on Haskell give a boost comparable to 64 bit bitboards on C?

Haskell on Reddit - Tue, 09/29/2015 - 3:38am

Bitboard wiki page describes the pros of BBs as:

The advantage of the bitboard representation is that it takes advantage of the essential logical bitwise operations available on nearly all CPUs that complete in one cycle and are fully pipelined and cached etc. Nearly all CPUs have AND, OR, NOR, and XOR. Many CPUs have additional bit instructions, such as finding the "first" bit, that make bitboard operations even more efficient. If they do not have instructions well known algorithms can perform some "magic" transformations that do these quickly.

Furthermore, modern CPUs have instruction pipelines that queue instructions for execution. A processor with multiple execution units can perform more than one instruction per cycle if more than one instruction is available in the pipeline. Branching (the use of conditionals like if) makes it harder for the processor to fill its pipeline(s) because the CPU can't tell what it needs to do in advance. Too much branching makes the pipeline less effective and potentially reduces the number of instructions the processor can execute per cycle. Many bitboard operations require fewer conditionals and therefore increase pipelining and make effective use of multiple execution units on many CPUs.

CPUs have a bit width which they are designed toward and can carry out bitwise operations in one cycle in this width. So, on a 64-bit or more CPU, 64-bit operations can occur in one instruction. There may be support for higher or lower width instructions. Many 32-bit CPUs may have some 64-bit instructions and those may take more than one cycle or otherwise be handicapped compared to their 32-bit instructions.

If the bitboard is larger than the width of the instruction set, then a performance hit will be the result. So a program using 64-bit bitboards would run faster on a real 64-bit processor than on a 32-bit processor.

So my question is these advantages of Bitboards are on a very low level can I expect to get these advantages while using Haskell? Is the Haskell compiler (I am using the garden variety GHC) capable enough to implement these optimizations? Also, if anyone could suggest me something (good) to read on how haskell compilation works, that would be great.(I am just starting out in Haskell and Func Programming)

submitted by thezbk
[link] [9 comments]
Categories: Incoming News

Johan Tibell: Video of my performance optimization talk at ZuriHac 2015

Planet Haskell - Tue, 09/29/2015 - 12:28am

This blog post is a couple of months late, but I thought I should mention that a talk on performance optimization I gave a while ago at ZuriHac 2015 is now on YouTube (slides). Unfortunately the first minutes got cut off and the sound quality isn't the best, but hopefully it's something.

P.S. I will be giving a rewritten and expanded version of this talk at Haskell eXchange 2015.

Categories: Offsite Blogs

Separate words based on non-letters

Haskell on Reddit - Mon, 09/28/2015 - 11:49pm

I'm trying to define a function that will take a string (with no new line characters) and separate the string into words, where a word is just any combination of letters. So, any non-letters should be considered as separators.

I know that if I am given a string

str: "abc def ghi jkl mno"

Then I could separate the words based on whitespace:

words str => ["abc","def","ghi","jkl","mno"]

But now suppose the string was this:

str: "abc def ghi jkl mno&pqr$stu."

I would like to be able to separate the above string to get this output:

["abc", "def", "ghi", "jkl", "mno", "pqr", "stu"]

where the "words" can be separate by any character that isn't a letter, and all leading/trailing non-letters are not considered part of the word (so they are treated in the same way white space would be treated)

One possible solution: perhaps if I could replace all non-letters (not a-z or A-Z) with a whitespace, I could just use "words" normally?

submitted by CodeShadow
[link] [9 comments]
Categories: Incoming News

Getting an Int from IO

Haskell on Reddit - Mon, 09/28/2015 - 11:20pm

I am very new to haskell and I am trying to get input from the user and use that input as an int. How do you convert an IO int to a normal int or how do you use an IO int?

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

Help with Haskell I/O

Haskell on Reddit - Mon, 09/28/2015 - 11:19pm

I am trying to create a haskell function that reads input from the user, one integer at a time, and creates a list from the input. I want it to continue accepting input until the user enters an exit integer (0). I am able to read input until a zero is entered, but I am having trouble figuring out how to put that information in a list. Any help would be greatly appreciated!

submitted by Lurkers7
[link] [2 comments]
Categories: Incoming News

Using Parsec with a recursive data as the stream

haskell-cafe - Mon, 09/28/2015 - 10:36pm
Hello, I've posted this question in StackOverflow[1], but I thought this would be a good place to ask too: I'm writing an interpreter for functional programming language with with *mixfix operators*, just like Agda[2]. I used their paper[3] as reference. if_then_else_ : Bool -> a -> a -> a if True then x else _ = x if False then _ else x = x _/\_ : Bool -> Bool -> Bool True /\ True = True _ /\ _ = False So that means I had to run a parser (I used Alex/Happy), to get an AST, with this specific part (smaller than actual `Expr`): data Expr = Id String | Apply [Expr] | Forall Type Expr data Type = TypeBind String Expr And with this `Expr`, I have to run a second parser (which I intend to use Parsec) to do the following kind of processing: λ let example = Apply [Id "if", Id "a", Id "/\\", Id "b", Id "then", Id "c", Id "else", Id "d"] λ parseMixfix example Right (Apply [Id "if_then_else_",Apply [Id "_/\\_",Id "a",Id "b"],Id "c",Id "d"]) I s
Categories: Offsite Discussion

Quick Help: Combining elements of a Haskell list of lists

Haskell on Reddit - Mon, 09/28/2015 - 9:59pm

I have the following Haskell list:

A: [(1,["a", "b", "b", "c"]), (2,["a", "dd"])]

and I want it to look like this Haskell list

B: [(1,"a"), (1,"b"), (1,"b"), (1,"c"), (2,"a"), (2,"dd")]

I know this should be really simple, but I'm new at Haskell. I feel like this can be done in one line..

Also, is there an easy way to search this type in Hoogle?

Thank you!

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

Help Wanted: Collecting ints from the input stream

Haskell on Reddit - Mon, 09/28/2015 - 8:56pm

Hello everyone, I am very new to Haskell and I am currently trying to figure out how to read in integers from the input stream in Haskell. From my understanding, input can only be read with the use of a main = do block and the input comes in as an IO string. Am I wrong in this understanding, and if not, how do I convert an IO string into an int?

submitted by Dasani9591
[link] [1 comment]
Categories: Incoming News

Symbolic Calculus

Haskell on Reddit - Mon, 09/28/2015 - 7:34pm
Categories: Incoming News

Issue deriving MonadTrans for chained custom monad transformers.

Haskell on Reddit - Mon, 09/28/2015 - 5:36pm

I've have the following monad transformer and monad type from the RWST monad:

{-# LANGUAGE GeneralizedNewtypeDeriving #-} newtype ZoneT m a = Zone { runZone :: RWST ZoneDescription ZoneLog ZoneState m a } deriving (Functor , Applicative , Monad , MonadTrans , MonadWriter ZoneLog , MonadState ZoneState , MonadReader ZoneDescription , MonadRWS ZoneDescription ZoneLog ZoneState) type Zone = ZoneT Identity

After defining a set of monadic functions for this monad, I wanted to build a second monad that uses the Zone monad as a base, but adds another piece of immutable state and exception throwing capabilities:

newtype CommandT m a = Command { runCommand :: ReaderT Tag (ExceptT String (ZoneT m)) a } deriving (Functor , Applicative , Monad , MonadTrans , MonadReader Tag , MonadError String) type Command = CommandT Identity

However, when I try to compile, GHC gives me the following error:

Can't make a derived instance of ‘MonadTrans CommandT’ (even with cunning newtype deriving): cannot eta-reduce the representation type enough In the newtype declaration for ‘CommandT’

And with that prelude, here are my questions:

  • Is there any way to automatically derive all the classes from the runner's type? (Thus avoiding having to list them.)
  • What does GHC's error really mean? What are the necessary and sufficient conditions for successful MonadTrans derivation in this situation?
  • Is there an error I've made that will resolve this situation and allow me to derive MonadTrans for CommandT after all?

I'm still learning my way around monads and transformers, so any high level feedback/comments are absolutely appreciated as well.


So, I thought about it, and I realized that the implementation of lift for CommandT is simply its constructor, Command. I proved this by simply chaining Command with N lifts to lift any of CommandT monads into the Command monad.

However, I expected this to allow me to simply use lift instead of the constructor:

instance MonadTrans CommandT where lift = Command

Unfortunately, it resulted in a few compilation errors. What are the nuances of implementing MonadTrans that prevent me from doing this?

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

Removing latency spikes. Garbage collector related?

glasgow-user - Mon, 09/28/2015 - 5:08pm
Hi, I was told in the #haskell IRC channel that this would be a good place to ask this question, so here goes! We’re writing a low-latency messaging system. The problem is we are getting a lot of latency spikes. See this image: (yellow to red is the 90th percentile), which shows end-to-end latency of messages through the system. I have tried to eliminate the problem by removing parts of the system that I suspected to be expensive, but the spikes are still there. I’m now thinking that it’s the GC. As you can see in this output from ghc-events-analyze, work on the GC thread (red) seems to be blocking work on the main program thread (green) (x axis is time, darkness of buckets is % CPU time). *Note: the graphs are not of the same run, but are typical* Do you think the GC is the most likely culprit? Is there anything I can do to confirm this hypothesis? (I looked into turning off the GC, but this seems tricky) If it is the GC, then is there
Categories: Offsite Discussion

ranges and tuples

Haskell on Reddit - Mon, 09/28/2015 - 1:36pm
Categories: Incoming News

ETAPS 2016 final call for papers

General haskell list - Mon, 09/28/2015 - 11:01am
****************************************************************** CALL FOR PAPERS: ETAPS 2016 19th European Joint Conferences on Theory And Practice of Software Eindhoven, The Netherlands, 2-8 April 2016 ******************************************************************
Categories: Incoming News