@DiazCarrete@hachyderm.io avatar

DiazCarrete

@DiazCarrete@hachyderm.io

This profile is from a federated server and may be incomplete. Browse more on the original instance.

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

AFAIK, there's not an easy way in Haskell to inspect at the type level what type a field has in a record.

What I mean is that that there doesn't seem to be a type family like

type FieldType :: Type -> Symbol -> Type

that we could invoke in ghci like

:kind! FieldType Person "age"

Why would I want this? For libraries like servant and rel8 that use parameterized records where the types of the fields vary heavily with the type parameter.

I guess I could hack it using generics. 🤔

DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar

If your branch has a good number of commits since it diverged from main, rebasing can sometimes seem like a Sisyphean task. Because each commit is applied independently, you often end up resolving merge conflicts again and again in the same places, conflicts that a merge would make you resolve together in one go.

To avoid that, I sometimes squash together all the commits in my branch before rebasing on top of main. But then of course I lose the structure of the separate commits.

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

The library lets you construct queries using a monadic interface.

Interesting bit: "Rel8 has a fairly unique feature in that it’s able to return not just lists of rows, but can also return trees."

https://rel8.readthedocs.io/en/latest/cookbook.html#tree-like-queries

image/png

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

When building Servant applications with persistence, a common (?) pattern is to request a database connection from a pool in the callback we pass to "hoistServer" https://hackage.haskell.org/package/servant-server-0.20/docs/Servant-Server.html#v:hoistServer and then pass the connection down to the handler using ReaderT https://github.com/danidiaz/comments-project/blob/3bb720124b31f0a8e351751bdcc6651ed75d9e27/comments/lib/Comments/Runner.hs#L57
It works, but I'm kinda unhappy about it because it forces you to use ReaderT in those intermediate components that lie between the top-level handler and the repository component which actually uses the connection. 😕

DiazCarrete, to vim
@DiazCarrete@hachyderm.io avatar

9.1 released, including support for classes in Vimscript! Now I can finally adopt it as my my primary programming language. (Just kidding, of course... It already was.)
🔗 https://www.vim.org/vim-9.1-released.php
🔗 https://vimhelp.org/vim9class.txt.html#vim9-class

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

friendship ended with ScopedTypeVariables, TypeAbstractions is my new best friend
https://serokell.io/blog/ghc-dependent-types-in-haskell-3

DiazCarrete, (edited ) to haskell
@DiazCarrete@hachyderm.io avatar

I know that Megaparsec doesn't backtrack automatically and that you have to use "try" for that, but this behavior of "many" was unexpected. Why oh why doesn't it parse the final space?
https://stackoverflow.com/a/78355045/1364288
Maybe I didn't read the documentation thoroughly, but I don't think it's actually spelled out in the Haddocks?

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

"Nesting APIs and ReaderT environments with Servant"
https://nicolashery.com/nesting-reader-environments-servant/

DiazCarrete, to programming
@DiazCarrete@hachyderm.io avatar
DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

In Servant, the ServerError type has an Exception instance
https://hackage.haskell.org/package/servant-server-0.20/docs/Servant-Server.html#t:ServerError
You might speculate that when throwing a ServerError using liftIO . throwIO in a Handler, the ServerError is automatically caught and served as a response, but it ain't so: it's treated as just another exception, and the response code is 500.

Instead, you should throw ServerErrors using "throwError", re-exported from the "Servant" module.
https://hackage.haskell.org/package/servant-server-0.20/docs/Servant.html#v:throwError

image/png

DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar
DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar

cabal init --non-interactive --no-comments --dependency="base, servant, servant-server, servant-blaze, blaze-html, blaze-htmx"

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar
DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

Rel8 is a library that teeters between "looking at the instances provides much useful information" and "looking at the instances causes psychic damage".
https://hackage.haskell.org/package/rel8-1.5.0.0/docs/Rel8.html#t:Table

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

Even after enabling the DuplicateRecordFields, NoFieldSelectors and OverloadedRecordDot triad, record update for ambiguous fields remains a pain, often alleviated with lens libraries like "generic-lens".

Explicitly deconstructing and constructing values might be an alternative in some cases.
🔗 https://discourse.haskell.org/t/first-release-of-derive-has-field-derive-hasfield-instances-for-records/7723/6?u=danidiaz
🔗 https://gist.github.com/danidiaz/1659defe71d5d51ae042e001c98014ae

DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar

CSS has made me afraid of heights 😔📏

DiazCarrete, (edited ) to random
@DiazCarrete@hachyderm.io avatar
DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar

I hate package-by-layer so fucking much. "Hey, see this cohesive set of files that together implement a feature? Let's spread them over the four corners of the codebase and send you in fun little Easter egg hunts every two minutes".

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar
DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar

"nix run" is super convenient.

Although I struggled to figure out how to run the secondary executable of a package. "nix shell" with the "--command" flag did the trick.

https://determinate.systems/posts/nix-run
https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-run
https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-shell
https://github.com/NixOS/nix/issues/4498

DiazCarrete, (edited ) to random
@DiazCarrete@hachyderm.io avatar

Researching some doubts I had about serialized theading mode and prepared statements.

It seems that sharing a prepared statement between threads is bad news, even in serialized mode.
🔗 https://www.sqlite.org/threadsafe.html
🔗 https://sqlite.org/forum/forumpost/9d87fe7c8e
🔗 https://sqlite-users.sqlite.narkive.com/6l92EAHJ/serialized-prepared-statement-clarification

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

lots of info about HKD techniques in this thread

https://discourse.haskell.org/t/hkd-best-or-worst-thing-ever/9450

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

Made a video: generating HTML in Haskell using "lucid2"
https://www.youtube.com/watch?v=SQ78GVCzsz0

DiazCarrete, to programming
@DiazCarrete@hachyderm.io avatar
DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • cubers
  • magazineikmin
  • GTA5RPClips
  • khanakhh
  • InstantRegret
  • Youngstown
  • mdbf
  • slotface
  • thenastyranch
  • everett
  • osvaldo12
  • kavyap
  • rosin
  • anitta
  • DreamBathrooms
  • Durango
  • modclub
  • ngwrru68w68
  • vwfavf
  • ethstaker
  • tester
  • cisconetworking
  • tacticalgear
  • Leos
  • provamag3
  • normalnudes
  • JUstTest
  • All magazines