# News aggregator

### Is there any fast, industrial strength lambda calculator, that reduces a LC term to its normal form, even inside abstractions?

I'm interested in a programming language that allows me to write a lambda term such as:

(λ k → ((λ a → k a) (λ x → x)))And get, as result, its normal form:

(λ k → k (λ x → x))I want the interpreter to normalize even inside abstractions. This is obviously impossible in Haskell itself since, as a practical (and lazy) language, it uses closures and doesn't allow for function inspection. So, if you write:

f k = (\ a -> k a) (\ x -> x)There isn't really any way to ask GHC for f's normal form. I could easily write a lambda calculus DSL on Haskell, yes, but, as any DSL, it wouldn't be as efficient as I want. I'm looking for an industrial strength, fast lambda calculator. There are many toy/educational lambda calculators around, but I'm looking for something that can normalize large scale programs efficiently. Any idea?

submitted by SrPeixinho[link] [6 comments]

### Refactoring question

Hello all

I'm working with some code that is basically building up commands to be processed. The idea would be that you can say something like:

fetch $ Field `eq` 10 -- NOTE: which type we're filtering on is inferred from contextas well as:

fetch $ ParentField `j` ChildField `j` ChildChildField `eq` 10So I ended up with:

fetch :: (a -> commands) -> m [a] j :: (cl, commands) -> cr -> (clr, commands) eq :: (c, commands) -> cval -> ct -> commands -- NOTE: ct here is just used to force eq to match fetch's return contextBut this leaves me having to provide a special function for making the first column suitable to compose with the rest of them.

j' :: c -> (c, commands) j' c = (c, []) -- Just an example, not actual implementationSo I didn't like a few things about this. I didn't like that the initial commands had to be done on the first column instead of fed in by fetch. So I factored the tuple of column + commands to be a function that takes commands and returns the column + commands tuple. This puts me at:

fetch :: (a -> commands -> commands) -> m [a] j :: (commands -> (cl, commands)) -> cr -> commands -> (clr, commands) eq :: (commands -> (c, commands)) -> cval -> ct -> commands -> commandsWhich composes as before, but now instead of having to supply an empty commands for the first column, I have to "lift" it like this

fetch $ (\x -> (ParentField, x)) `j` ChildField `j` ChildChildField `eq` 10or in the case of a single column

fetch $ (\x -> (Field, x)) `eq` 10I think what is throwing me off here is that I'm working with functions that need two arguments, where as a straight implementation of State monad would take one argument [1].

There must be a way to clean up this interface though. I looked into arrows to see if they could help me, but so far I haven't come up with anything. Anyone have any ideas?

[1] What I mean here is that the "lift" function obviously looks like State return/pure and the j function looks like >>= for state except for that extra cr parameter.

submitted by nicheComicsProject[link] [1 comment]

### Composing arguments

While developing a visual representation for Haskell I noticed again the similarity between applying a function to several arguments and applying a composition of functions to a single argument. This lead me to thinking about composing arguments. Here's the code:

{-# LANGUAGE RankNTypes #-} type WFull a b = (a -> b) -> b type WSame a = WFull a a type W a = forall b . (a -> b) -> b wrap :: a -> WFull a b wrap x = ($ x) unwrap :: WSame a -> a unwrap x = x id apply :: WSame a -> (a -> b) -> WFull b c apply f x = wrap $ x (unwrap f) composeArgs :: (a -> b) -> (b -> c) -> a -> c x `composeArgs` y = (y.x) composeFunc :: WSame (b -> c) -> WSame (a -> b) -> WFull (a -> c) d composeFunc f g = wrap $ (unwrap f).(unwrap g)To use it:

> ((*).(+2)) 3 4 > 20 > unwrap $ apply (wrap (*) `composeFunc` wrap (+2)) (wrap 3 `composeArgs` wrap 4) > 20A version of this code that uses an abstract data type is on Github here. My conclusion is that a visual language that has argument composition would still represent valid Haskell programs.

Edit: Removed "realized" since the focus of this post is composing arguments.

submitted by RobbieGleichman[link] [22 comments]

### Discussion: Add unboxed mutable references somewhere sensible

### Does Haskell have any use in real world? That can not be acomplished by traditional sequential programming (iterative, I believe it's called).

Most of the applications I've seen are just remakes of some other ones but in Haskell. Based on this, why should I give up a good chunk of my time to learn Haskell than giving up a good chunk of my time to learn more about say C++ (OpenGL, Unreal etc) or C# (QT, Unity).

submitted by Zyborg23[link] [12 comments]

### GHC Hackaton (GHC internals) slides

### Applying for Haskell opportunities at Facebook

### Applying for Haskell opportunities at Facebook

### Applying for Haskell opportunities at Facebook

### Rationale for two separate map functions inClassyPrelude

### Is there a good, succinct, metaphor-free Monad tutorial?

A couple months ago, after finally "getting" Monads and do-notation, I was hit with a sense that the answer was very anti-climactic. I was also kind of annoyed, because it felt like this allegedly-complicated thing could be explained *much* more succinctly, without any cute language, without any metaphors, without allusions to any other programming languages, and in a way that really sticks.

Basically, start by assuming a competent reader.

Then demonstrate data types, and then pattern-based overloading.

Don't say things like, "Haskell is about *composability*". (That meant nothing for a few chapters.)

Instead, talk about:

- function-composition
*operators*like the '.' in "f . g x" (and '.' is a great starting point, because most people remember it from math class); - the fact that such operators allow chaining as in "f3 . f2 . f1 x" (again, easy-to-grasp);
- if they know any POSIX shell scripting (or even scripting with cmd.exe), talk about the shell pipe operator as another kind of function-composition operator that allows chaining with "command1 <x | command2 | command3" (ok, so there's
*one*metaphor, except that it's not that far off); - the fact that Haskell encourages the use of many different kinds of function-composition operators;
- the fact that >>= is one such operator, which naturally leads into
- the fact that >>= allows operations on x to be chained as in "x >>= f1 >>= f2 >>= f3"; and
- the fact that >>= is defined using the same pattern-based overloading mentioned earlier (so that the >>= evaluated at run-time depends on the left-side operand).

Then talk about do-notation de-sugaring, monad laws to show when the nesting lambdas are equivalent to the above chaining... and then you're pretty much done.

(And if they're confused in any particular part of that, they can ask, and we can answer with a couple of simple examples.)

*Then* you can talk about composability.

For someone with experience in C, C++, Python, or Java, that should be doable in a very short time.

And then the reader (or viewer---maybe it should be a Khan Academy-style video) can understand simple programs that use IO inside do-notation in main, and then they can understand why such programs can behave correctly even though, at first glance, they don't seem to check e.g. for EOF or the absence of IO errors.

Wouldn't it have been nice if all that had been laid out for you on day one so that you could actually make sense of small, practical programs?

But then, maybe I just didn't look in the right place. Does a tutorial like that exist already?

**[EDIT]** /u/bss03 was one of several to give me a good reason why I don't want to try writing any such tutorial at this time.

False alarm, everyone! (:

Thanks to everyone who posted a link, especially Dan Burton, who just re-posted his Zero-Analogy blog entry in response to this thread.

**[EDIT 2]** Do any of these links belong in the sidebar?

[link] [101 comments]

### Regex-applicative and Data.Text

### Anonymous FFI calls

### svgcairo/ghc vis cabal install error..

### Ben Moseley: FTP dangers

My first and biggest concern is simply that it's harder to

*read*code which uses highly polymorphic functions unnecessarily.

You can see that even by considering plain-old fmap vs map: it's harder to read "fmap f . fmap g" than "map f . map g" because with the former you're having to manually search for more information about what Functor is being used in each case.

My second concern is that the more you overload, the more you risk having something unexpected happen:

Say we have two variables:

*Borders.Base.Utils> let a' = ["alice", "bob"]

*Borders.Base.Utils> let a = (True, a')

we want to count the characters so we type:

*Borders.Base.Utils> length $ concat a

..but we've accidentally forgotten the prime character...

... right now we get:

<interactive>:6:17:

Couldn't match expected type ‘[[a0]]’

with actual type ‘(Bool, [[Char]])’

In the first argument of ‘concat’, namely ‘a’

In the second argument of ‘($)’, namely ‘concat a’</interactive>

so we fix it and get our desired result:

*Borders.Base.Utils> length $ concat a'

8

...but under the FTP proposals (where concat would become Data.Foldable.concat) we get:

*Borders.Base.Utils> length $ Data.Foldable.concat a

2

(because pairs are Foldable in their second argument).

This cannot be a good thing.

I believe that the more generalised functions of FTP should be

*opt-in*(i.e. you should - as at present - need to import them explicitly).

### Having problems with my indention and alignment in notepad++, after working on a .lhs script for a while when I reopened it today I found everything to be unaligned. please help!

I'm working on a Haskell program which is currently over 500 lines. I'm very careful to make sure all my functions have neat and identical alignment but I have opened notepad++ today to discover that all my functions are no longer aligned neatly and the whole thing looks a mess. As far as I'm aware I've not done anything and it seems to be the case with all my scripts, wondered if anyone had any idea what is going on?

Here's an example of what I mean

fun :: Int -> Int fun a = aHas become

fun :: Int -> Int fun a = aI know it's not super important but it's very frustrating and wondered if anyone knew a fix?

EDIT: I'm an idiot thanks for all your help its sorted now!

submitted by LJackso[link] [15 comments]