Posts

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

DiazCarrete, to accessibility
@DiazCarrete@hachyderm.io avatar

"ARIA is polyfill for HTML semantics"
https://x.com/SaraSoueidan/status/1791379249045053443

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

exa,
@exa@mastodon.online avatar

@DiazCarrete
+1 for the other suggestion here: do not eat space before the lexemes (as beginner tutorials tend to show) -- always eat it after the lexemes (and only after the lexemes!), and do it reliably. Hard-learned lesson.

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

@DiazCarrete IIRC, we don't "try" by default because it can cause excessive backtracking, and having that even be a possibility holds references to things, increasing memory usage, and decreasing performance.

So, yeah, anytime you want to "noncommittally consume", you have to use try explicitly.

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

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

DiazCarrete,
@DiazCarrete@hachyderm.io avatar

In which I completely mispronounce "lucid", among many other words.

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

The history of the concept of "bean" in Java frameworks. It has undergone quite a bit of drift!

https://www.youtube.com/watch?v=Z5hxolai4Tk

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

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

"hack it using generics"
^ oh god, my poor memory. I actually did already implement something like this back in the day, using generics.

https://hackage.haskell.org/package/red-black-record-2.1.4.0/docs/Data-RBR.html#t:Value

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

I've published "dani-servant-lucid2" on Hackage. It's a tiny package that provides a HTML content type for Servant, backed by the "lucid2" HTML library.
https://hackage.haskell.org/package/dani-servant-lucid2
https://github.com/danidiaz/dani-servant-lucid2

There was already an integration for an earlier version of lucid https://hackage.haskell.org/package/servant-lucid but not for lucid2. https://github.com/haskell-servant/servant-lucid/issues/26

Also, "dani-servant-lucid2" has a public sublibrary with extra definitions, but it seems as if Hackage doesn't display info for public sublibraries yet.

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

@BoydStephenSmithJr I don't think it's a bad idea!

I believe we can impement in Servant the throwIO behavior I mentioned earlier by catching (some) runtime exceptions in the callback passed to "hoistServer" and re-throwing them in the "proper" way expected by Handler. https://hackage.haskell.org/package/servant-server-0.20/docs/Servant-Server.html#v:hoistServer

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

@DiazCarrete I think that universally quantified x might be a problem, but I suppose it depends on the type of your re-throw mechanism.

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

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

@DiazCarrete That's what I do, yes. newtype Semantic2 = MkSemantic2 { unSemantic2 :: Semantic1 }

Though sometimes I do something different, like newtype Subset = AssertSubset { asSuperset :: Superset } for things where the rep. sharing is more practical, even if the syntax isn't actually the same, like Email/Text or PhoneNumber/Int64 since construction will generally be through something like isEmail :: Text -> Either ParseFailure Email or inputPhone :: Natural -> Maybe PhoneNumber

kosmikus,
@kosmikus@functional.cafe avatar

@DiazCarrete I think both are nice to have.

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

https://hackage.haskell.org/package/network-uri-2.6.4.2/docs/Network-URI.html#g:2
https://www.ietf.org/rfc/rfc2396.txt
https://webmasters.stackexchange.com/a/56844/89929

"A relative reference that begins with a single slash character is termed an absolute-path reference. A relative reference that does not begin with a slash character is termed a relative-path reference."

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