35 Matching Annotations
  1. Aug 2020
    1. Commonly the above definition is called the identity function. But in fact we should think of it as a whole family of functions. We should really say that id is an identity function for all types a. In other words, for every type T you might come up with, there is an identity function called id, which is of type T -> T. This is the type-checker’s view anyway, and by turning on the RankNTypes extension we can be explicit about that in our code: {-# LANGUAGE RankNTypes #-} id :: forall a. a -> a id x = x

      This is such a nice description of forall. It should be combined with forall is the type-level "lambda" (also saved it here).

    2. Now it is much clearer that id is really a family of infinitely many functions. It is fair to say that it is an abstract function (as opposed to a concrete one), because its type abstracts over the type variable a. The common and proper mathematical wording is that the type is universally quantified (or often just quantified) over a.

      This was very neatly put, and forall above is also spot on.

    3. It also adds safety through a property called parametricity. If we pretend that there are no infinite loops or exceptions (it’s okay to do that, so we will do it throughout this article), then the function is actually fully determined by its type. In other words, if we see the type a -> a, we know that the corresponding value must be the identity function.

      If this would be the first time I came across parametricity, I wouldn't understand what it means.

      https://en.wikipedia.org/wiki/Parametricity

      In programming language theory, parametricity is an abstract uniformity property enjoyed by parametrically polymorphic functions, which captures the intuition that all instances of a polymorphic function act the same way.

      That is, a function with the type signature a -> a has only one implementation: it can only return its input. In a similar fashion, a -> b -> a will only return the first argument and ignore the second. And so on.

    4. In other words you cannot choose the definition of a value based on its type (for now).

      What does this mean?

  2. Jul 2020
  3. May 2020
    1. function (or in the case of type classes, we call these methods)
    2. If you can tell that two types are equal or not equal, that type belongs in the Eq type class.

      two types or rather two things of the same type?

    1. Programming languages These will probably expose my ignorance pretty nicely.

      When to use different programming languages (advice from an Amazon employee):

      • Java - enterprise applications
      • C# - Microsoft's spin on Java (useful in the Microsoft's ecosystem)
      • Ruby - when speed is more important then legibility or debugging
      • Python - same as Ruby but also for ML/AI (don't forget to use type hinting to make life a little saner)
      • Go/Rust - fresh web service where latency and performance were more important than community/library support
      • Haskell/Erlang - for very elegant/mathematical functional approach without a lot of business logic
      • Clojure - in situation when you love Lisp (?)
      • Kotlin/Scala - languages compiling to JVM bytecode (preferable over Clojure). Kotlin works with Java and has great IntelliJ support
      • C - classes of applications (operating systems, language design, low-level programming and hardware)
      • C++ - robotics, video games and high frequency trading where the performance gains from no garbage collection make it preferable to Java
      • PHP/Hack - testing server changes without rebuilding. PHP is banned at Amazon due to security reasons, but its successor, Hack, runs a lot of Facebook and Slack's backends
  4. Apr 2020
  5. Mar 2020
  6. Feb 2020
    1. Nix is a purely functional package manager. This means that it treats packages like values in purely functional programming languages such as Haskell — they are built by functions that don’t have side-effects, and they never change after they have been built.
  7. Nov 2019
    1. haskell-overridez is a tool and library of nix functions that simplify the use of overrides while developing haskell projects with nixpkgs.

  8. Jun 2019
    1. This package takes a more declarative approach, and talks about events rather than signals. Widgets emit event values, and these values can be mapped and transformed into other values as the event propagates up the tree of widgets.

      So this is a bit more elm-y than it would otherwise be

  9. Apr 2019
  10. Mar 2019
  11. Feb 2019
    1. Haskell

      Haskell, Keep it simple, stupid.

      -- FizzBuzz
      module Main where
      
      import Control.Monad
      
      main :: IO ()
      main = forM_ [1..100] $ \n -> putStrLn . concat . take 2 $
          ["Fizz" | n `mod` 3 == 0] ++ 
          ["Buzz" | n `mod` 5 == 0] ++ 
          ["", show n]
      
  12. Jan 2019
  13. Oct 2018
  14. Sep 2018
  15. Apr 2018
    1. (== 10)

      This confused me. I'm relatively new to Haskell and did not know about sectioning. After learning that detail, this makes sense as a (right) partial application of the (==) function.

  16. Jan 2018
    1. Whereas normal type classes represent predicates on types (each type is either an instance of a type class or it isn’t), multi-parameter type classes represent relations on types
  17. Oct 2017
  18. Apr 2017
  19. Dec 2016
  20. Oct 2016
  21. Jul 2016
    1. Saw this recommended on a Quora answer whilst looking for book and article recommendations for a newcomer to Haskell

  22. Jun 2016
  23. May 2016
  24. Oct 2014
    1. foldMap :: Monoid m -> (a -> m) -> t a -> m

      I'm not sure, but I think what he meant here was foldMap :: Monoid m => (a -> m) -> t a -> m.

    2. The notion behind it was that one could decompose, e.g., Applicative into an instance of the Pointed typeclass and an instance of the Apply typeclass (giving apply :: f (a -> b) -> f a -> f b) and an instance of Pointed, such that the two interact properly.

      There's more on Applicative (and Functor) here, in case you're unfamiliar with it.