@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

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

"I recently merged linear let- and where-bindings in GHC. Which means that we’ll have these in GHC 9.10"
🔗 https://www.tweag.io/blog/2024-01-18-linear-desugaring/

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

Interesting: it seems that is moving towards typechecking desugared expressions in some cases, instead of typechecking the surface syntax.

The tricky part is not making the error messages worse.

https://youtu.be/LFIL0myeOlo?list=PLyrlk8Xaylp5ahGXwF_NvYEhVOnedRIAs&t=469

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

"the very definition of the GHC profiler makes it of limited use when estimating time on two classes of computations: firstly, those that need to do blocking IO; and secondly, some computations that invoke functions written in other programming languages."
https://www.tweag.io/blog/2022-07-28-timestats/
Sometimes you have to turn to the eventlog
https://well-typed.com/blog/2019/09/eventful-ghc/
https://hackage.haskell.org/package/ghc-events
https://downloads.haskell.org/ghc/latest/docs/users_guide/eventlog-formats.html

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 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, (edited ) to random
@DiazCarrete@hachyderm.io avatar

IIUC, of the two main algorithms for topological sorting in directed acyclic graphs, only Kahn's algorithm allows you to give extra priority to some vertices, so that they appear earlier in the resulting ordering.

🔗https://en.wikipedia.org/wiki/Topological_sorting
🔗 https://jgrapht.org/javadoc-1.0.0/org/jgrapht/traverse/TopologicalOrderIterator.html#TopologicalOrderIterator-org.jgrapht.DirectedGraph-java.util.Queue-
🔗 https://www.cs.fsu.edu/~lacher/lectures/Output/graphs1/slide09.html

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

Generating safe links for your REST API with Servant
https://youtu.be/KC64Ymo63hQ?si=I_E17cwA0UBQfmAF

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, to haskell
@DiazCarrete@hachyderm.io avatar

Wrote a toy dependency injection library for . inductive tuples, graph topological sorting and dynamic typing under the hood.
https://discourse.haskell.org/t/cauldron-a-toy-dependency-injection-framework/8092

DiazCarrete, to haskell
@DiazCarrete@hachyderm.io avatar

> writes dynamically typed code example
> only compiles it, doesn't even run it once 🤷
🔗 https://discourse.haskell.org/t/implementing-type-safe-heterogeneous-collections/8605/5
🔗 https://github.com/danidiaz/toyframes/blob/main/README.md

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
DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar

A History of Subtyping—Benjamin C. Pierce
🔗 📽️ https://www.youtube.com/watch?v=SiUBXvpo2eI

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

Still getting the hang of pattern synonyms.

🔗 https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/pattern_synonyms.html
🔗 https://gitlab.haskell.org/ghc/ghc/-/wikis/pattern-synonyms#explicitly-bidirectional-pattern-synonyms
the paper 🔗 https://repository.brynmawr.edu/compsci_pubs/68/

It seems that, if you want to check for some value-level condition when matching, you need to bring in ViewPatterns. This is mentioned in the wiki but not (explicitly) in the GHC user guide.

DiazCarrete, to random
@DiazCarrete@hachyderm.io avatar

I was trying to reproduce some of the laziness issues described in this old (2016) but very in-depth article at the Well-Typed blog:
https://well-typed.com/blog/2016/09/sharing-conduit/
But I'm not able to reproduce them when compiling with -O2 --rtsopts (and using GHCRTS=-M20m to limit the size of the heap so that it fails faster in case of a leak) on GHC 9.6.2.

I wonder what has changed in the meantime.
https://gist.github.com/danidiaz/512aaf61e068a650ba5d4908758e30bd

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 haskell
@DiazCarrete@hachyderm.io avatar
DiazCarrete, (edited ) to random
@DiazCarrete@hachyderm.io avatar
DiazCarrete, (edited ) to haskell
@DiazCarrete@hachyderm.io avatar
DiazCarrete, to CSS
@DiazCarrete@hachyderm.io avatar

I've found tricky to set a vertical scrollbar on a component, when we don't want to set an explicit height in the component itself, and instead want it to consume leftover vertical space from an ancestor that has "height: 100vh;"

I've managed to achieve it by spraying "display: flex" and "flex-grow: 1" across the ancestor chain, but I wonder if there's a better way. 🤔

JSFiddle 🔗 https://jsfiddle.net/cm6rL1ny/
GitHub 🔗 https://github.com/danidiaz/html-experiments/blob/1434d95f1c1b4c9ab2124b52b8d06557b1f01bf3/vertical-scrollbar/index.html#L5

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

Checking if the "algebraic-graphs" library allows vertices to connect to themselves. (It does.)

And if you remove an edge, the vertices stay in the graph.

So, if I wanted to remove self-loops (to be able to perform topological sorting) I could get the list of vertices and repeatedly call "removeEdge".

https://hackage.haskell.org/package/algebraic-graphs

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, (edited )
@DiazCarrete@hachyderm.io avatar

"I got rid of ReaderT and now my application is hanging by a thread"
https://discourse.haskell.org/t/i-got-rid-of-readert-and-now-my-application-is-hanging-by-a-thread/9330

  • 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