Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    A

    Apocalisp

    apocalisp.wordpress.com · Personal blog · on HN since 2008

    Runar Bjarnason writes about functional programming, type systems and Scala, with posts on Java, Haskell-style iteratees and type theory.

    Visit blogHN submissions
    Languages & CompilersProgramming
    What HN says

    HN commenters link his post that the Liskov Substitution Principle is contravariance, and his structural pattern matching in Java as a pattern for avoiding isinstance checks.

    Stats for nerds
    23HN people shared it
    13linked in comments
    134story points
    Jan 2025last shared
    2010people per year2025

    Top posts on HN

    1. 1
      Imperative vs Functional Programming
      1 person · 81 points · first shared 2011 · 66 comments on HN
    2. 2
      Arguments in favor of pure functional programming
      1 person · 32 points · first shared 2009 · 21 comments on HN
    3. 3
      Structural Pattern Matching in Java
      4 people · 8 points · first shared 2009 · 1 comments on HN
    4. 4
      Liskov Substitution Principle is Contravariance (2010)
      4 people · 4 points · first shared 2013 · Discussion on HN
    5. 5
      Enumeration-Based I/O in Scala using Haskell-style Iteratees
      2 people · 3 points · first shared 2010 · Discussion on HN
    6. 6
      Heterogeneous Lists and the Limits of the Java Type System (2008)
      1 person · 3 points · first shared 2016 · Discussion on HN
    7. 7
      Objects, Identity, and Concept-Formation
      1 person · 1 points · first shared 2012 · Discussion on HN
    8. 8
      Towards an Effect System in Scala, Part 2: IO Monad
      1 person · 1 points · first shared 2011 · Discussion on HN
    9. 9
      Noumenal Null: Null vs. Pure Reason
      1 person · 1 points · first shared 2008 · Discussion on HN
    10. 10
      Type level programming in scala part 4a peano number basics
      2 people · first shared 2010

    What HN people wrote when they linked it

    • pkaJul 2012

      So, Java's HashMap.get() should throw a checked exception whenever the value is not found in the map? That would sure eliminate a lot of boilerplate code :)

      Aren't exceptions meant to be used for, well, exceptional cases only, i.e. when no matter what, execution really can't be continued? It makes sense for a lot of functions to return some sort of "Nothing" value instead of raising an exception, but the problem is that in many languages there is no explicit "Nothing" value, so people just abuse null.

      You can have Maybe in Java too, but getting out a value or a Nothing out of a Maybe value is just not enforced by the compiler due to the lack of algebraic data types and pattern matching; still, it is an improvement over null hell. On a side note, Maybe is called Option in Scala.

      By the way, exceptions are monads, they are just predefined in most languages in a way you can not change. If you want a lengthy Java centric read about that I would strongly recommend checking out [1]. Ant here's another if you're ok with reading Haskell [2].

      Also for the record, in Haskell you can use the ErrorMonad in place of the Maybe monad if you want precise error reporting capabilities.

      [1] http://apocalisp.wordpress.com/2008/05/16/thrower-functor

      [2] http://www.haskell.org/haskellwiki/Exception

    • narratorJun 2010

      When I get a compiler error in Scala it's almost always something that would cause a runtime error in a non statically typed language. The downside is that the error messages can be difficult to parse and resolve for beginners. Once I got over the learning curve, I realized that in almost all cases the compiler was trying to tell me something very useful. I do get a little annoyed at all the Haskell/OCaml type nerds trying to do things with the type system that are not particularly practical, for instance: http://apocalisp.wordpress.com/2010/06/16/type-level-programming-in-scala-part-4a-peano-number-basics/

    • fharsNov 2011

      That is not a simple type. And people who still remember the original Pascal will know that you do not want to encourage people to make the size part of the collection type. And it doesn't buy you much if you cannot prove at compile time that the type you use to index into the collecton cannot overflow the collection bounds. Use Ada if you need that.

      But if you want you can also encode the sizes in binary or decimal numbers:
      http://apocalisp.wordpress.com/2010/06/24/type-level-programming-in-scala-part-5a-binary-numbers/ http://www.ict.kth.se/forsyde/files/tutorial/apas03.html

    • PeakerJan 2012

      Well, Scala has advantages and disadvantages over Haskell, but I wouldn't say it is more "powerful" than Haskell.

      Consider the implementation of a properly lazy "const" function in Haskell:

      const x _ = x

      And in Scala:

      http://apocalisp.wordpress.com/2010/04/21/a-proper-constant-function-in-scala/

      Not sure about Coq, but Agda is Turing Complete (you just need to turn off termination checks) and Epigram also supports general recursion as well as structural recursion with total functions.

    • tiew9ViiMar 2022

      This may be a useful pattern to you. The example is in Java but you should be able to achieve the same in Python https://apocalisp.wordpress.com/2009/08/21/structural-pattern-matching-in-java/.

      It’ll get rid of the ‘isinstance’ and give exhaustive matching. I used to use this pattern a lot when wanting ADT’s in a language without ADT’’s.

    • platzJan 2015

      apparently LSP is just a contravariant functor https://apocalisp.wordpress.com/2010/10/06/liskov-substitution-principle-is-contravariance/

      But I don't see how the relationship of contravariant functors to OO-style subclasses is as clear as the DI <-> function abstraction example (functions are just functions in OO or FP)

    Related

    Runar Bjarnasonblog.higher-order.com21 people

    Maximally Powerful, Minimally Useful

    Runar Bjarnason
    Personal · last shared 2023
    Patrick Thomsonblog.sumtypeofway.com15 people

    An Introduction to Recursion Schemes (2014)

    Patrick Thomson
    Personal · last shared 2024
    Aditya Bhargavaadit.io68 people

    Functors, applicatives, and monads in pictures

    Aditya Bhargava
    Personal · last shared 2025
    Justin Leblog.jle.im36 people

    Typesafe Neural Networks in Haskell with Dependent Types

    Justin Le
    Personal · last shared 2026
    Conal Elliottconal.net156 people

    Can functional programming be liberated from the von Neumann paradigm? (2010)

    Conal Elliott
    Personal · last shared 2026
    Alexis Kinglexi-lambda.github.io172 people

    Parse, Don’t Validate

    Alexis King
    Personal · last shared 2026
    Lennart Augustssonaugustss.blogspot.com42 people

    BASIC as a Haskell DSL (2009)

    Lennart Augustsson
    Personal · last shared 2025
    FP Complete Blogfpcomplete.com201 people

    Monads and GATs in Nightly Rust

    FP Complete Blog
    Company · last shared 2025