# News aggregator

### Conal Elliott » Early inspirations and new directions in functional reactive programming

### Obfuscated haskell attempt

[link] [10 comments]

### Haskell-programming sysadmin opportunity at SFLC

### What is {-# ... #-} in the beginning of most haskell programs?

I am new to Haskell (and programming in general). I have seen many haskell programs that begin with {-# LANGUAGE (something here) #-}. What is this? What does it accomplish? Is it Haskell's version of shebang?

submitted by srivkrani[link] [55 comments]

### Type and function naming conventions

A substantial program has many names. What conventions do you use to name them? I'm asking about function names and type names that are exported from a module, including data constructors.

I see many random StackOverflow questions on this topic and scattered other blog posts and such, but most of these are about object-oriented languages. Does anyone have good conventions for a functional language?

Also, what suggestions exist for how heavily to rely on the module system to disambiguate names, and how much to use typeclasses purely for naming purposes? I tried the one data type per module style, but I did not find it to be clearly superior and the fact that it breaks too many tools and conventions (makes default Haddocks worthless) led me to abandon that idea.

Sometimes I have to name something so nebulous that I resort to random short, but memorable words. When I saw a package with Biff, Tannen, Joker, and Clown as names, I knew I am not alone in this problem.

I used to routinely name fields using record syntax, but this results in an explosion of mostly useless names so now I tend to avoid records for small types whose data constructors are exported.

*what I'm not talking about*:

short vs long variable names for local bindings that aren't exported from a module

whether things like Monoid should not be given allegedly scary-sounding names

whether type variables should have long names or use a single letter

[link] [10 comments]

### Curry arguments on a structure of functions, then fold with composition

**Motivation/Pattern**

**Definition**

**Some more toy examples**

It seems to me that <-> is applying functions to arguments in a way that is "perpendicular" to function composition.

**Operator Label**

Apparently, then Lens library contains a function ?? that is defined identically (thanks, zxamt, for pointing this out). In the use-case that I described above, I think that labeling the operator as ?? conveys very little information about what it does. In contrast, something like <-> is more readable because it looks like a function being applied to arguments.

**Discussion**

Any comments on this pattern/style?

**UPDATE: Bifunctors!**

It is easy to generalize the operator to Bifunctors (or indeed multi-functors):

(<-->) :: (Bifunctor f) => f (a -> b) (a -> c) -> a -> f b c fab <--> a = bimap ($a) ($a) fabExample:

split :: Integral a => a -> a -> (a,a) unsplit :: Integral a => a -> (a,a) -> a split k i = (div, mod) <--> i <--> k unsplit k (d, m) = k * d + m -- (split, unsplit) <--> k :: Integral a => (a -> (a,a), (a,a) -> a) composeTuple :: (b -> c, a -> b) -> a -> c composeTuple (f,g) = f . g -- For all k: composeTuple $ (split, unsplit) <--> k = id -- For all k: composeTuple $ (unsplit, split) <--> k = id**UPDATE**

Apparently, this is an operation that works on any "representable functor". There is a whole post on it in Comonad.Reader. From the article:

distributeReader :: Functor f => f (r -> a) -> (r -> f a) distributeReader fra = \r -> fmap ($r) fraAs you can see, distributeReader is the same as <->. The article is the third in a series on applicatives. There is also a memoization library based on this idea.

submitted by newestHaskeller[link] [8 comments]

### wren gayle romano: An introduction to recursive types

The past couple weeks I've been teaching about recursive types and their encodings in B522. Here's a short annotated bibliography for followup reading:

- For a basic intro to recursive types, and for the set-theoretic metatheory: see section IV, chapters 20 and 21.
- Benjamin C. Pierce (2002)
*Types and Programming Languages.*MIT Press.

- Benjamin C. Pierce (2002)
- The proof of logical inconsistency and non-termination is "well-known". For every type τ we can define a fixed-point combinator and use that to exhibit an inhabitant of the type:
- fixτ = λf:(τ→τ). let e = λx:(μα.α→τ). f (x (unroll x)) in e (roll(μα.α→τ) e)
- ⊥τ = fixτ (λx:τ. x)

- A category-theoretic proof that having fixed-points causes inconsistency
- Hagen Huwig and Axel Poigné (1990)
*A note on inconsistencies caused by fixpoints in a Cartesian Closed Category.*Theoretical Computer Science, 73:101–112.

- Hagen Huwig and Axel Poigné (1990)
- The proof of Turing-completeness is "well-known". Here's a translation from the untyped λ-calculus to STLC with fixed-points:
- (x)* = x
- (λx. e)* = roll(μα.α→α) (λx:(μα.α→α). e*)
- (f e)* = unroll (f*) (e*)

- Knaster–Tarski (1955): For any monotone function, f, (a) the least fixed-point of f is the intersection of all f-closed sets, and (b) the greatest fixed-point of f is the union of all f-consistent sets.
- Alfred Tarski (1955)
*A lattice-theoretical fixpoint theorem and its applications.*Pacific Journal of Mathematics 5(2):285–309. - Bronisław Knaster (1928)
*Un théorème sur les fonctions d'ensembles.*Annales de la Société Polonaise de Mathématique, 6:133–134.

- Alfred Tarski (1955)
- For a quick introduction to category theory, a good place to start is:
- Benjamin C. Pierce (1991)
*Basic Category Theory for Computer Scientists.*MIT Press.

- Benjamin C. Pierce (1991)
- For a more thorough introduction to category theory, consider:
- Jiří Adámek, Horst Herrlich, and George Strecker (1990)
*Abstract and Concrete Categories: The Joy of Cats.*John Wiley and Sons.

- Jiří Adámek, Horst Herrlich, and George Strecker (1990)
- The Boehm–Berarducci encoding
- Oleg Kiselyov (2012)
*Beyond Church encoding: Boehm–Berarducci isomorphism of algebraic data types and polymorphic lambda-terms* - Corrado Boehm and Alessandro Berarducci (1985)
*Automatic Synthesis of Typed Lambda-Programs on Term Algebras.*Theoretical Computer Science, v39:135–154

- Oleg Kiselyov (2012)
- Church/Boehm–Berarducci encodings are not canonical
- [citation needed]

- Surjective pairing cannot be encoded in STLC (i.e., the implicational fragment of intuitionistic propositional logic): see p.155
- Morten H. Sørensen and Paweł Urzyczyn (2006)
*Lectures on the Curry–Howard isomorphism.*Studies in Logic and the Foundations of Mathematics, v.149.

- Morten H. Sørensen and Paweł Urzyczyn (2006)
- However, adding it is a conservative extension
- Roel de Vrijer (1987)
*Surjective Pairing and Strong Normalization: Two themes in lambda calculus.*dissertation, University of Amsterdam. - Roel de Vrijer (1989)
*Extending the lambda calculus with surjective pairing is conservative.*4th LICS, pp.204–215. - Kristian Støvring (2005)
*Extending the Extensional Lambda Calculus with Surjective Pairing is Conservative.*BRICS.

- Roel de Vrijer (1987)
- Compiling data types with Scott encodings
- Jan Martin Jansen, Pieter Koopman, and Rinus Plasmeijer (200X)
*Data Types and Pattern Matching by Function Application.* - Jan Martin Jansen, Pieter Koopman, and Rinus Plasmeijer (2006)
*Efficient Interpretation by Transforming Data Types and Patterns to Functions.*Trends in Functional Programming. - Jan Martin Jansen, Rinus Plasmeijer, and Pieter Koopman (2010)
*Comprehensive Encoding of Data Types and Algorithms in the λ-Calculus.*J. Functional Programming. - Pieter Koopman, Rinus Plasmeijer, and Jan Martin Jansen (2014)
*Church encoding of data types considered harmful for implementations.*IFL submission

- Jan Martin Jansen, Pieter Koopman, and Rinus Plasmeijer (200X)
- For more on the difference between Scott and Mogensten–Scott encodings:
- Aaron Stump (2009)
*Directly Reflective Meta-Programming.*J. Higher Order and Symbolic Computation, 22(2):115–144.

- Aaron Stump (2009)
- Parigot encodings
- M. Parigot (1988)
*Programming with proofs: A second-order type theory.*ESOP, LNCS 300, pp.145–159. Springer.

- M. Parigot (1988)
- For more on catamorphisms, anamorphisms, paramorphisms, and apomorphisms
- Varmo Vene and Tarmo Uustalu (1998)
*Functional programming with apomorphisms (corecursion).*In Proc. Estonian Acad. Sci. Phys. Math., 47:147–161 - Erik Meijer, Maarten Fokkinga, and Ross Paterson (1991)
*Functional Programming with Bananas, Lenses, Envelopes, and Barbed Wire.*In Proc. 5th ACM conference on Functional programming languages and computer architecture, pp.124–144

- Varmo Vene and Tarmo Uustalu (1998)
- build/foldr list fusion
- Andy Gill, John Launchbury, and Simon Peyton Jones (1993)
*A short cut to deforestation.*In Proc. Functional Programming Languages and Computer Architecture, pp.223–232. - Many more links at the bottom of this page

- Andy Gill, John Launchbury, and Simon Peyton Jones (1993)
- For another general introduction along the lines of what we covered in class
- Philip Wadler (1990)
*Recursive types for free!*

- Philip Wadler (1990)
- "Iterators" vs "recursors" in Heyting arithmetic and Gödel's System T: see ch.10:
- Morten H. Sørensen and Paweł Urzyczyn (2006)
*Lectures on the Curry–Howard isomorphism*Studies in Logic and the Foundations of Mathematics, v.149.

- Morten H. Sørensen and Paweł Urzyczyn (2006)
- There are a great many more papers by Tarmo Uustalu, Varmo Vene, Ralf Hinze, and Jeremy Gibbons on all this stuff; just google for it.

comments

### Haskell-programming SysAdmin opportunity at Software Freedom Law Conservancy

### Toby Goodwin: Hiatus

I've decided to take a break from flare / MPv6 during the month of
April, and work on my other projects. No doubt I have more ideas than
I'll have time for, but here's a quick brainstorm of things I *could*
do:

- tweak the design of this website a bit
- consider moving to hakyll
- rc: get it into fedora
- rc: new release fixing known problems
- pacc / rc integration
- pacc: get it into debian, fedora
- rc and pacc: arch, nixos??
- pacc: develop left recursion ideas
- pacc: replace make with shake?

Looking at the above, I think my plan will be as follows.

- Fix some rc problems; make new release.
- Do some more work on rc-pacc.
- See if I can make any headway on left recursion.
- Look at getting things into distros.

Conveniently, there are 4 weeks in the month, so that's one week on each item. Oh, but I should get the wheels turning on becoming a Fedora contributor straight away. There's plenty to work through!

### Chalmers is advertising positions, deadline April 6

### Announcing: LTS (Long Term Support) Haskell 2

### Hindley Milner and Scott Encodings

Ive been playing around with Hindley Milner and Scott encodings, I'd love to know what you all think, especially those who know more about (sub)types than I.

https://gist.github.com/stelleg/9d0182ac16dc54370e36

Thanks!

submitted by stelleg[link] [11 comments]

### FARM 2015: 2nd Call For Papers

### Is `race (readChan a) (readChan b)` safe?

Or what about race (threadDelay n) (readChan a)?

Golang has that select thing for selecting from multiple chans, but I'd guess that it's been checked for correctness.

race, however, looks like it could make one of the actions in a half-assed state. What do y'all make of this?

submitted by hxr[link] [5 comments]