Haskell

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

Anyone in my (or other, I guess) circles in charge of www.cs.nott.ac.uk ? It was working yesterday, but it keeps timing out (for me) today.

I need to re-read the section of blampied-thesis.pdf on the prefix functor, and especially how it works when the non-uniform type is self-nested in interesting ways.

Trying to do a "project :: t -> f t" and keep getting hung up on the Scope-modified recursions.

Alternatively, is that thesis available elsewhere? I searched, but haven't found.

duplode,
@duplode@mathstodon.xyz avatar
BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

@duplode Nice! That should work. I thought I searched archive.org, but I guess I didn't do it well.

jesper,

This is a great blog post on the WellTyped blog on specialization in Haskell! It's a good reminder that I (or someone) should really get around to getting rid of -fexpose-all-unfoldings and -fspecialize-agressively in the Agda codebase.

well-typed.com/blog/2024/04/choreographing-specialization-pt1/

(Also I didn't know about -flate-specialise and -fpolymorphic-specialisation, though I think I'd rather avoid relying on even more flags.)

Jose_A_Alonso,
@Jose_A_Alonso@mathstodon.xyz avatar

The Haskell Unfolder Episode 23: specialisation. ~ Edsko de Vries (@EdskoDeVries), Andres Löh (@kosmikus). https://www.youtube.com/live/ksW04Cl2dgo

fargate,

Helsinki Haskell Users Group's first book club had its conclusion meeting today with Sockets and Pipes coming to its very end. It has been a ride, one with plenty of scheduling difficulties, but I think we only fell like a month and a half from the original planned schedule and actually had a member retention rate of 100% (of members who were there in the beginning, sadly we could not quite make it 133%)!

To talk a bit about the book as a whole, I do feel like I understand Monad Transformers a lot better now though I'll still need to reread the sections introducing them I am sure. ReaderT especially was something I could see was colossally handy, but given it was in the second to last chapter we were already quite deep with trying to understand everything else so the true utility of it remains somewhat hazy despite the quality of the chapter itself which felt higher than those surrounding it. The habit of reading RFCs and attempting to match the spec in the types one writes is also one I should include in my general workflow, though that is probably a no-brainer for most. It just wasn't a thing in my previous work, so bear with me while I call it a novel concept!

I'm still working on my personal project, but getting nix-build working seems difficult. I'll just have to bring it up in the next main group Office Hours meetup I suppose, lest I never get this show on the road!

haskell,
@haskell@fosstodon.org avatar

@fargate congratulations :)

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

Any experience with turning non-uniform recursion schemes (http://www.cs.nott.ac.uk/Research/fop/blampied-thesis.pdf) into a library that works like or -schemes

I've got a specific type that uses a approach but I'd like to write some general folds (using e.g. algebra families) instead of duplicating the "traversal" code.

I might have done the categorical approach (functor categories instead of algebra families) before, but that has limitations and I think I lost the code.

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

You might say "Well, that's not a problem, just make those intermediate components that don't care about the connection polymorphic over MonadUnliftIO! Later, when composing the application, they will be injected a repository that does know about the ReaderT and the connection. Problem solved."

That's true, but what if I wanted those intermediate components to be as dumb as possible? Just plain records of functions in IO, no monad transformers, and no polymorphism over the monad, either?

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

flora_pm, French
@flora_pm@functional.cafe avatar

Only very few breakages from Flora's dependencies with GHC 9.10.1-alpha3. We may be able to adopt it as soon as HLS supports it (and a nice dose of "allow-newer" in cabal.project configuration)

flora_pm,
@flora_pm@functional.cafe avatar
haskell_foundation,
@haskell_foundation@mastodon.social avatar

GHC 9.6.5 is now available! This release focuses on fixing bugs discovered in the 9.6 series. Check out the details https://www.haskell.org/ghc/blog/20240416-ghc-9.6.5-released.html

haskell,
@haskell@fosstodon.org avatar

GHC 9.6.5 bugfix release is now available!
Read the announcement at https://discourse.haskell.org/t/ghc-9-6-5-is-now-available/9341

haskell,
@haskell@fosstodon.org avatar

GHC 9.10.1-alpha3 is now available!
Read the announcement at https://discourse.haskell.org/t/ghc-9-10-1-alpha3-is-now-available/9336

haskell,
@haskell@fosstodon.org avatar

This release brings exciting new things, like:
• The GHC2024 Language Edition
• Type Arguments to functions
• Backtrace information in exceptions

You can read about them in the release notes: https://downloads.haskell.org/ghc/9.10.1-alpha3/docs/users_guide/9.10.1-notes.html

kosmikus,
@kosmikus@functional.cafe avatar

New blog post by my colleague Finley on "Choreographing a dance with the GHC specializer (Part 1)". This is in addition to our episode on the same topic tomorrow, 2024-04-16, at 1830 UTC on YouTube.

https://well-typed.com/blog/2024/04/choreographing-specialization-pt1/

[Well-Typed Blog] Choreographing a dance with the GHC specializer (Part 1) (well-typed.com)

This is the first of a two-part series of blog posts on GHC specialization, an optimization technique used by GHC to eliminate the performance overhead of ad-hoc polymorphism and enable other powerful optimizations. There will also be a Haskell Unfolder episode about this topic.

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

Anyone know if the images (e.g.: https://hub.docker.com/layers/fpco/stack-build/lts-22/images/sha256-09dcc6cf3739dbb5f73bbb84dc15ee815f463409653c5159673afc7d3b4134b7?context=explore) are still maintained, and what might be the best way to report a bug? :blobfoxconfused:

The LTS_SLUG seems wrong, and when I attempt a stack build in that image, I run out of space compiling GHC. (e.g.: https://gitlab.com/bss03/restman/-/jobs/6622698704) :blobfoxsurprised:

I expect the docker image would contain a GHC that stack would find and use; I am using the matching resolver for the tag (e.g.: 22.17). :blobfoxhappy:

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

@simonmic Done-ish (mostly linked to my post here)

On a separate note, how portable is my account? I just picked element since it seemed like a zero-install option. If I use matrix more, I might want to switch clients to something that integrates will with KDE.

simonmic,
@simonmic@fosstodon.org avatar

I believe I'm right in saying you can use your account with any web-based or local #matrix client.

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

I opened two merge requests on a project (hosted on ) that I don't "own". I think that's enough for the day. 😀

haskell, (edited )
@haskell@fosstodon.org avatar

The Cryptography Group calls for early adopters of its , and one-time-password libraries! https://discourse.haskell.org/t/call-for-early-adopters-of-sel-botan-and-one-time-password/9326

DiazCarrete,
@DiazCarrete@hachyderm.io avatar

TIL that operations on IORefs (unlike some operations on MVars) are are guaranteed not to be interruptible.

https://hackage.haskell.org/package/base-4.19.1.0/docs/Control-Exception.html#g:13

maralorn, (edited )
@maralorn@chaos.social avatar

After extensively using the library for half a year at work I have now played around with the library again. I am amazed by how much more helpful error messages are with . It’s an amazing library and I would recommend it over whenever you have the choice.

maralorn,
@maralorn@chaos.social avatar

@mangoiv Hasn’t been my impression with yet. To me it feels like the type level stuff is "finished". As long as you only define and use existing types of optics you don’t need to worry about it.

mangoiv,
@mangoiv@functional.cafe avatar

@maralorn sounds really good! I think I might actually wanna try them at work.

brokenix,
@brokenix@emacs.ch avatar

pseq combinator is used for sequencing; informally, it eval-
uates its first argument to weak-head normal form, and then eval-
uates its second argument, returning the value of its second argu-
ment. Consider this definition of parMap:
parMap f [] = []
parMap f (x:xs) = y ‘par‘ (ys ‘pseq‘ y:ys)
where y = f x
ys = parMap f xs
The intention here is to spark the evaluation of f x, and then
evaluate parMap f xs, before returning the new list y:ys. The
programmer is hoping to express an ordering of the evaluation: first
spark y, then evaluate ys.
The obvious question is this: why not use #Haskell’s built-in seq
operator instead of pseq? The only guarantee made by seq is that
it is strict in both arguments; that is, seq a ⊥ = ⊥ and seq ⊥
a = ⊥. But this semantic property makes no operational guaran-
tee about order of evaluation. An implementation could impose this
operational guarantee on seq, but that turns out to limit the optimi-
sations that can be applied when the programmer only cares about
the semantic behaviour. Instead, we provide both pseq and seq
(with and without an order-of-evaluation guarantee), to allow the
programmer to say what she wants while leaving the compiler with
as much scope for optimisation as possible.
https://simonmar.github.io/bib/papers/multicore-ghc.pdf

sgraf,
@sgraf@mastodon.online avatar

@brokenix ironically, the implementation of pseq is broken today https://gitlab.haskell.org/ghc/ghc/-/issues/23233 and probably has been broken since inception

kosmikus,
@kosmikus@functional.cafe avatar

It's finally time for the next episode of the . In episode 23, my colleagues Finley, Edsko, and I will discuss the topic of "specialisation", an important GHC optimisation that can help eliminate the cost intrinsic to overloaded functions. This will be streamed live on YouTube, on Tuesday, 2024-04-16, at 1830 UTC. https://www.youtube.com/watch?v=ksW04Cl2dgo&list=PLD8gywOEY4HaG5VSrKVnHxCptlJv2GAn7&index=23

DiazCarrete,
@DiazCarrete@hachyderm.io avatar
DiazCarrete,
@DiazCarrete@hachyderm.io avatar

I have wondered about this myself:

(24:30) https://youtu.be/fFCcvsbCrH8?t=1468

"registry"-like approaches do seem to make it easier to reuse previously assembled application contexts because the wiring is done through a dictionary-like data structure. You can easily overwrite any key with a different implementation, or with a mock.

Relatedly, they also seem to make it easier to draw diagrams of component dependencies:
https://hackage.haskell.org/package/registry-0.6.1.0/docs/Data-Registry-Dot.html
https://github.com/danidiaz/cauldron/blob/700dafb64ed932eee8b66356e35196c586d7e24c/lib/Cauldron.hs#L123

jaror,
jaror avatar

@DiazCarrete That slide seems to misrepresent effect systems. It is easy to replace just runInputConst:

runAllEffects (runInputDifferently program)

The runInputDifferently effect handles the Input Config effect and it leaves an unused Input Config in the list of effects. So the runInputConst config handler in runAllEffects will not be used.

sellout,

I made a thing in case you were starting to think programming is too easy.

https://github.com/sellout/no-recursion – a plugin to remove support from

(I have multiple use cases for this, I swear.)

sellout,

@boarders This is one of my use cases. The great thing about recursion schemes is that they don’t require recursion. And all streaming can be done with recursion schemes, so also no recursion.

But currently it’s pretty basic. You can use recursive functions from other modules … as long as they don’t get inlined. And there’s no way to restrict imported recursive functions. But please, open issues with stuff you’d like to see.

boarders,
@boarders@mathstodon.xyz avatar

@sellout ah fantastic, I want the same thing (I actually wanted it as a language extension similar to explicitly letrec, but dont currently have faith in the language proposal process as it attracts a lot of lawyer types)

For the guarded recursion thing, I had in mind coinductive programming which can be done with recursion schemes for coalgebra or with have an explicit tick operator as in guarded type theory / agda

6d03,
@6d03@mathstodon.xyz avatar

I remember recently reading a new paper elaborating a novel presentation of graph algebras. But I can't for the life of me remember the title or the author.

The central idea was axiomatizing vertices as pairs of sets of all incoming and outgoing edges.

It also had example code in Haskell.

Does anybody have an idea of the title? I'd be very thankful for suggestions.

victor_tokarev,
6d03,
@6d03@mathstodon.xyz avatar

@victor_tokarev that's the one. thank you very much.

jaror,
jaror avatar

Declarative vs imperative:

let v = sum [ ((x ! i) - m) ^ 2 | i <- [0 .. cc - 1] ] / fromIntegral cc
float v = 0.0f;
for (int i = 0; i < C; i++) {
    float xshift = x[i] - m;
    v += xshift * xshift;
}
v = v/C;
jaror,
jaror avatar

Admittedly it gets more complicated when summing two things at the same time:

let Pair dnormMean dnormNormMean = 
      fold (Pair <$> dimap (\(Pair _ dnormI) -> dnormI) (/ fromIntegral cc) sum
                 <*> dimap (\(Pair normBti dnormI) -> normBti * dnormI) (/ fromIntegral cc) sum)
        $ map (\i -> Pair (((inp ! (off + i)) - meanBt) * rstdBt)
                          ((weight ! i) * (dout ! (off + i))))
          [0 .. cc - 1]
float dnorm_mean = 0.0f;
float dnorm_norm_mean = 0.0f;
for (int i = 0; i < C; i++) {
    float norm_bti = (inp_bt[i] - mean_bt) * rstd_bt;
    float dnorm_i = weight[i] * dout_bt[i];
    dnorm_mean += dnorm_i;
    dnorm_norm_mean += dnorm_i * norm_bti;
}
dnorm_mean = dnorm_mean / C;
dnorm_norm_mean = dnorm_norm_mean / C;
  • All
  • Subscribed
  • Moderated
  • Favorites
  • haskell
  • DreamBathrooms
  • InstantRegret
  • osvaldo12
  • magazineikmin
  • tacticalgear
  • rosin
  • cisconetworking
  • Youngstown
  • ngwrru68w68
  • slotface
  • Durango
  • kavyap
  • mdbf
  • thenastyranch
  • JUstTest
  • everett
  • GTA5RPClips
  • cubers
  • tester
  • khanakhh
  • Leos
  • provamag3
  • ethstaker
  • modclub
  • anitta
  • megavids
  • normalnudes
  • lostlight
  • All magazines