941 karma · joined February 14, 2009
The TWSBI Swipe supports both cartridges and converters.
https://www.scala-lang.org/blog/2017/04/01/announcing-skala....
Sometimes we all just put up with the unreadable mess when it solves the problem at hand quickly.
The whole point of using types is making inconsistent states type bugs. Types are logic.
This article presents a great example: https://fsharpforfunandprofit.com/posts/designing-for-correc...
Having to deal with online calendars being off by one hour for a week is not that bad in comparison, we are already used to that :)
• You have a producer of Cs, then you can turn it into a producer of Ds by post-processing its output with a function g: C → D.
• You have a consumer of Bs, then you can turn it into a consumer of As by pre-processing its input with a function f: A → B.
• You have something that consumes Bs and produces Cs, then you can turn it into something that consumes As and produces Ds using two functions f: A → B and g: C → D.
With pictures: http://mez.cl/prodcons.png
If you understand that, you understand functors:
• producer = (covariant) functor;
• consumer = contravariant functor;
• producer-consumer = invariant functor;
• post-processing = map;
• pre-process = contramap;
• pre- and post-processing = xmap (in Scala), invmap (in Haskell);
• defining how the pre- and post-processing works for a given producer or consumer = declaring a typeclass instance.
It doesn't mean that "a functor is a producer", but the mechanics are the same.
!!41 === true
!!0 === falseIn hindsight, singleton tuples are not common or useful enough to deserve their own syntax. If the way to create them was something like this:
t = tuple.single("hello")
we'd thing it's ugly or inconsistent, but definitely not confusing or bug-prone. echo "I'm $(tput setaf 4)blue$(tput sgr0)."
but I couldn't get this one right without looking it up: echo -e "I'm \033[0;34mblue\033[0m." ≈3.14159