about summary refs log tree commit diff
path: root/nix_gcr
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-04-11T15·50+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-04-11T15·50+0100
commit3c8bfe85c9fb6dfa064cb1fc5bcc93af46cdd49f (patch)
tree7f5087f6169c51ab6fbe721af0979613015ff0ad /nix_gcr
parent52eb456a0f25913c44615c6828562eb19c94393b (diff)
Prefer type alias to type
Elm reminds me of Haskell. In fact, I'm using `haskell-mode` (for now) in Emacs
to write my Elm code, and it works reliably. I'm not writing a Haskell app, but
if I were, I would define my application Model with the following Haskell code:

```haskell
data Model = Model { whitelistedChords :: [Theory.Chord]
                   , selectedChord :: Theory.Chord
                   , isPaused :: Bool
                   , tempo :: Int
                   }
```

When I first modelled my application state, I did something similar. After
reading more Elm examples of SPAs, I see that people prefer using type aliases
to define records. As far as I know, you cannot do this in Haskell; I believe
all types are "tagged" (something about "nominal typing" comes to mind). Anyhow,
Elm isn't Haskell; Haskell has cool features like type classes; Elm has cool
features like human-readable error messages and exhaustiveness checking for
cases. I love Haskell, and I love Elm, and you didn't ask.

Anyhow, this commit refactors my records as type aliases instead of types. I
think the resulting code is more readable and ergonomic.
Diffstat (limited to 'nix_gcr')
0 files changed, 0 insertions, 0 deletions