Used writegood suggestions

This commit is contained in:
Yann Esposito (Yogsototh) 2020-03-09 23:55:55 +01:00
parent 5758c55904
commit e013898f2f
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
3 changed files with 152 additions and 48 deletions

View file

@ -4,12 +4,12 @@
#+author: Yann Esposito #+author: Yann Esposito
#+EMAIL: yann@esposito.host #+EMAIL: yann@esposito.host
#+keywords: Haskell, programming, functional, tutorial #+keywords: Haskell, programming, functional, tutorial
#+DESCRIPTION: A very dense introduction and Haskell tutorial. Brace yourself. #+DESCRIPTION: A dense introduction and Haskell tutorial. Brace yourself.
#+OPTIONS: auto-id:t toc:t #+OPTIONS: auto-id:t toc:t
#+STARTUP: overview #+STARTUP: overview
#+begin_notes #+begin_notes
A very short and intense introduction to Haskell. A short and intense introduction to Haskell.
This is an update of my old (2012) article. This is an update of my old (2012) article.
A lot of things have changed since then. A lot of things have changed since then.
@ -24,45 +24,49 @@ This is why I wrote my old article.
This is the end of 2019 and I still strongly believe that. This is the end of 2019 and I still strongly believe that.
I think you should at least be able to understand enough Haskell to write a I think you should at least be able to understand enough Haskell to write a
simple tool. simple tool.
There are a few feature in Haskell that I really miss in most programming There are some features in Haskell that I really miss in most programming
languages and that would not appear to be difficult to provide. languages and that would not appear to be difficult to provide.
Typically sum types. Typically sum types.
A concept so simple yet so helpful. A concept so simple yet so helpful.
Since I wrote my article a few things have changed in the Haskell world. Since I wrote my article the Haskell ecosystem has evolved:
1. Project building has a few working solution. When I wrote this article I 1. Project building has different existing solutions.
had a few web application that I can no longer build today. When I wrote this article I made some web applications that I can no
I mean, if I really want to invest some time, I'm sure I could make longer build today.
those project build again. But this is not worth the hassle. I mean, if I really want to invest some time, I'm sure I could upgrade those
Now we have =stack=, =nix=, =cabal new-build= and I'm sure some other projects to build again.
But this is not worth the hassle.
Now we have =stack=, =nix=, =cabal new-build= and I'm sure other
solutions. solutions.
2. GHC is able to do a lot more magic than then. 2. GHC is able to do a lot more magic.
This is beyond the scope of an introductory material in my opinion. This is beyond the scope of an introduction material in my opinion.
But, while the learning curve is as steep as before the highest point of While the learning curve is as steep as before, the highest point of
learning just jumped higher than before with each new GHC release. learning just climbed higher and higher with each successive new GHC release.
3. Still no real consencus about how to work, learn, and use Haskell. In my 3. Still no real consencus about how to work, learn, and use Haskell.
opinion there are three different perspective on Haskell that could In my opinion there are three different perspective on Haskell that
definitively change how you make decisions about different aspect of could definitively change how you make decisions about different aspect
Haskell programming. I believe the main groups of ideolgies are of Haskell programming.
application developers, library developers and even language (mostly I believe the main groups of ideolgies are application developers, library
GHC) developers. I kind of find those tensions a proof of an healthy developers and the main compiler (GHC) developers.
environment. There are different solutions to the same problems and that I find those tensions a proof of a healthy environment.
is perfectly fine. This is quite different when you compare to other There are different solutions to the same problems and that is perfectly
language ecosystems where decisions are more controlled or enforced. I fine.
feel fine with both approaches. But you must understand that there is This is different when you compare to other language ecosystems where
not really any central mindset within Haskeller unlike I can find in decisions are more controlled or enforced.
some other programming language communities. I feel fine with both approaches.
But you must understand that there is no central mindset within
Haskellers
unlike I can find in some other programming language communities.
4. I think that Haskell is now perceived as a lot more serious programming 4. I think that Haskell is now perceived as a lot more serious programming
language now. language now.
There are a lot more big projects written in Haskell not just toy A lot more big projects uses Haskell.
Haskell proved its utility to write succesful complex entreprise
projects. projects.
Thus Haskell as proved that it can be considered to write succesful
complex entreprise projects.
While the ecosystem evolved I believe that I myself have certainly matured. While the ecosystem evolved I believe that I myself have certainly matured.
Since 2013 I am paid to develop in Clojure. Since 2013 I'm paid to develop in Clojure.
Most of my personal side project are written in Haskell or in an I write most of my personal side projects in Haskell or in some
Haskell-inspired language. Haskell-inspired language.
As such I can follow two functional programming communities growth and As such I can follow two functional programming communities growth and
@ -83,7 +87,7 @@ With just a very few amount of Haskell features you will already be in
enviromnent with a *lot* of benefits as compared to many programming enviromnent with a *lot* of benefits as compared to many programming
languages. languages.
So enough talk, here is my old article updated with a few changes and So enough talk, here is my old article updated with a some changes and
cleanups. cleanups.
I also added a section about how to create a new project template with nix. I also added a section about how to create a new project template with nix.
@ -131,11 +135,11 @@ It is because it is hard that Haskell is interesting and rewarding.
Today, I could not really provide a conventional path to learn Haskell. Today, I could not really provide a conventional path to learn Haskell.
So I think the best I can do is point you to the [[https://www.haskell.org/documentation/][haskell.org]] documentation So I think the best I can do is point you to the [[https://www.haskell.org/documentation/][haskell.org]] documentation
website. website.
And you will see that most path involve a quite long learning process. And you will see that most path involve a long learning process.
By that, I mean that you should read a long book and invest a lot of hours By that, I mean that you should read a long book and invest a lot of hours
and certainly days before having a good idea about what Haskell is all about. and certainly days before having a good idea about what Haskell is all about.
In contrast, this article is a very brief and dense overview of all In contrast, this article is a brief and dense overview of all
major aspects of Haskell. major aspects of Haskell.
I also added some information I lacked while I learned Haskell. I also added some information I lacked while I learned Haskell.
@ -151,7 +155,7 @@ The article contains five parts:
- *Dive into the impure*: - *Dive into the impure*:
- Deal with IO; A very minimal example - Deal with IO; A minimal example
- IO trick explained; the hidden detail I lacked to understand IO - IO trick explained; the hidden detail I lacked to understand IO
- Monads; incredible how we can generalize - Monads; incredible how we can generalize
@ -231,7 +235,7 @@ Congratulations you should be ready to start now.
- =nix= is a generic package manager and goes beyond Haskell. - =nix= is a generic package manager and goes beyond Haskell.
One great good point is that it does not only manage Haskell packages but One great good point is that it does not only manage Haskell packages but
really a lot of other kind of packages. really a lot of other kind of packages.
This can be quite helpful if you need to depends on a Haskell package that This can be helpful if you need to depends on a Haskell package that
itself depends on a system library, for example =ncurses=. itself depends on a system library, for example =ncurses=.
- I use [[http://nixos.org/nix][=nix=]] for other projects unrelated to Haskell. - I use [[http://nixos.org/nix][=nix=]] for other projects unrelated to Haskell.
For example, I use the nix-shell bang pattern for shell script for which For example, I use the nix-shell bang pattern for shell script for which
@ -368,14 +372,14 @@ Applying a function with the same parameters always returns the same value.
/Laziness/ /Laziness/
Laziness by default is a very uncommon language design. Laziness by default is an uncommon language design.
By default, Haskell evaluates something only when it is needed. By default, Haskell evaluates something only when it is needed.
In consequence, it provides a very elegant way to manipulate infinite In consequence, it provides an elegant way to manipulate infinite
structures, for example. structures, for example.
A last warning about how you should read Haskell code. A last warning about how you should read Haskell code.
For me, it is like reading scientific papers. For me, it is like reading scientific papers.
Some parts are very clear, but when you see a formula, just focus and read Some parts are clear, but when you see a formula, just focus and read
slower. slower.
Also, while learning Haskell, it /really/ doesn't matter much if you don't Also, while learning Haskell, it /really/ doesn't matter much if you don't
understand syntax details. understand syntax details.

View file

@ -7,22 +7,104 @@
#+OPTIONS: auto-id:t toc:t #+OPTIONS: auto-id:t toc:t
#+STARTUP: overview #+STARTUP: overview
[[https://ethanschoonover.com/solarized/][Solarized]] is a well known and quite common colorscheme. The colorscheme of my website is the colorscheme I use for my terminal and
I used it for many years. most of my environment.
At first, you need to try it for some time.
But after a few weeks it is very hard to change.
It is very nice to use on a day to day in a terminal. This is inspired by both [[https://ethanschoonover.com/solarized/][Solarized]] and [[https://nordtheme.com][Nord]].
It has a low contrast which is quite valuable to prevent migraine.
Ethan Shoovnover its creator give plenty of information about how he So I used [[https://ethanschoonover.com/solarized/][Solarized]] for many years.
created it. And it was really difficult finding a new one that suits my taste.
I wanted a "grayer" or more yellow colorscheme. Stil I disliked the blue-green dark background.
So I kept the main principle and opened a few parameters. I wanted to change that background color.
Or having a grayer background.
Ethan Shoovnover the creator of Solarized gave plenty of information about
how he created it.
Also I stumbled upon the [[https://nordtheme.com][Nord]] theme.
And I really liked it.
But while the colors are great, it is not as easy to switch from light to
dark theme than with solarized because Solarized has a lot of nice
properties.
So I kept the main principle used to create Solarized but freed a few parameters.
The tint of the dark and light colors for the background and the text, as The tint of the dark and light colors for the background and the text, as
well as the contrast of the colors. well as the contrast of the colors.
And I created this minimal application in Purescript: And I created this minimal application in Purescript:
https://solaryzed.esy.fun https://solaryzed.esy.fun
It is still not perfect, because the real theme I use for my website as a
slightly bigger contrast for text.
Here is the CSS you could use:
#+begin_export html
<style>#colors div { display: inline-block; }</style>
<div id="colors">
<div style="background: hsl(218.82, 20.99%, 15.88%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b03">b03</div>
<div style="background: hsl(222.35, 16.5%, 20.2%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b02">b02</div>
<div style="background: hsl(222.35, 8.72%, 38.24%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b01">b01</div>
<div style="background: hsl(221.25, 6.56%, 47.84%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b00">b00</div>
<div style="background: hsl(220.0, 6.98%, 57.84%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b0">b0</div>u
<div style="background: hsl(222.86, 8.64%, 68.24%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b1">b1</div>
<div style="background: hsl(223.64, 26.83%, 91.96%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b2">b2</div>
<div style="background: hsl(223.64, 84.62%, 97.45%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b3">b3</div>
<div style="background: hsl(38.48, 36.22%, 49.8%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="y">y</div>
<div style="background: hsl(17.23, 38.52%, 47.84%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="o">o</div>
<div style="background: hsl(8.09, 35.74%, 51.18%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="r">r</div>
<div style="background: hsl(336.75, 33.06%, 52.55%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="m">m</div>
<div style="background: hsl(229.6, 32.75%, 55.1%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="v">v</div>
<div style="background: hsl(205.19, 52.19%, 50.78%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="b">b</div>
<div style="background: hsl(176.09, 75.0%, 36.08%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="c">c</div>
<div style="background: hsl(60.91, 28.7%, 45.1%); height: 60.0px; width: 60.0px; line-height: 60.0px; text-align: center" id="g">g</div>
</div>
#+end_export
#+begin_src css :tangle solaryzed.css
:root {
color-scheme: light dark; /* support color scheme */
--b03: #202631;
--b02: #2b313c;
--b01: #656b74;
--b00: #727781;
--b0: #989ea8;
--b1: #b0bac7;
--b2: #e5e8ed;
--b3: #f4f7ff;
--y: #a98d50;
--o: #aa6550;
--r: #b85a64;
--m: #af53b0;
--v: #846f93;
--b: #5679a4;
--c: #4c8493;
--g: #728b5c;
--bg: var(--b3);
--fg: var(--b02);
--fg0: var(--b0); /* lower contrast */
--bg2: var(--b2); /* second color block background */
--fg2: var(--b01); /* second color block foreground */
--acc: var(--o); /* accent color */
}
@media (prefers-color-scheme: dark) {
:root {
/* Dark */
--bg: var(--b03);
--fg: var(--b0);
--fg0: var(--b00); /* lower contrast */
--bg2: var(--b02); /* second color block background */
--fg2: var(--b1); /* second color block foreground */
--acc: var(--g); /* accent color */
}
}
body,.main {
background: var(--bg);
color: var(--fg);
}
#+end_src

View file

@ -0,0 +1,18 @@
:root {
--b03: #202631;
--b02: #2b303c;
--b01: #595e6a;
--b00: #727782;
--b0: #8c919b;
--b1: #a7abb5;
--b2: #e5e8f0;
--b3: #f3f6fe;
--y: #ad8c51;
--o: #a9664b;
--r: #af6256;
--m: #ae5e7d;
--v: #6774b2;
--b: #408cc3;
--c: #17a198;
--g: #939452;
}