Haskell

koz,
@koz@chaos.social avatar

Someone who knows #Haskell and ML: is there a writeup somewhere explaining how first-class modules (a la ML) can do similar things to Haskell type classes? I'm finding it hard to figure that out.

To give a more concrete case: suppose I wanted to write something like Control.Applicative, which provides an 'interface' Applicative with some methods, as well as functions that work for any Applicative. How would I do this with ML-style first-class modules?

jaror,
jaror avatar

@koz I would like to see such a comparison post too. In the meantime I found this stackoverflow question which contains a way to do it using an ML functor: https://stackoverflow.com/questions/48989663/monads-and-sml-modules. The obvious downside is that you have to explicitly state which monad to use at some point.

Another lesser known difference is that I believe you can't instantiate an ML signature with a polymorphic type. For example you can't write an instance of that MAPPABLE signature for a type like Map k v. At least not such that it is still polymorphic over the key type k.

dpwiz,
@dpwiz@qoto.org avatar

@koz Not quite your case, but “The next 500 module systems” paper gives a nice overview of the problem, bridging modules, type classes and records (and scopes!).

DiazCarrete,
@DiazCarrete@hachyderm.io avatar

Template Haskell tutorial (last updated 2021)

https://markkarpov.com/tutorial/th

image/png

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

Some proposals:

Explicit Splice Imports https://github.com/ghc-proposals/ghc-proposals/pull/412

Pure Template Haskell https://github.com/ghc-proposals/ghc-proposals/pull/655

Unicode Syntax for Template Haskell splice https://github.com/ghc-proposals/ghc-proposals/pull/647

Add support for executing TH splices on the host platform during cross compilation. https://gitlab.haskell.org/ghc/ghc/-/issues/24339

Allow splicing Stmt https://gitlab.haskell.org/ghc/ghc/-/issues/24953

Name should be spliceable https://gitlab.haskell.org/ghc/ghc/-/issues/24922

DiazCarrete,
@DiazCarrete@hachyderm.io avatar

Another Template Haskell tutorial, also from 2021
https://serokell.io/blog/introduction-to-template-haskell

maralorn,
@maralorn@chaos.social avatar

I have real trouble developing an intuition for NoDeepSubsumption.

I always only notice by sheer luck that changing

a . b $ c

to

a $ b $ c

fixes my type error.

BoydStephenSmithJr,
@BoydStephenSmithJr@hachyderm.io avatar

@maralorn I also still have problems with this in , too.

Best tip I have is to pay more attention to the 'forall's. Compose / . / <<< "fixes" the 'forall', which can cause type checking to fail elsewhere or, if "a" is higher-rank, there (it forces "b" to be monomorphic; higher-rank "a" might require a polymorphic "b'). Application / '$' (in GHC) doesn't "fix" the forall.

I think the difference might be "deeper", but for me it's able where the "choice" for the forall is made.

mangoiv,
@mangoiv@functional.cafe avatar

My favourite row polymorphism package is aeson

aeveltstra,
@aeveltstra@mastodon.social avatar

@mangoiv Why aeson?

lxsameer,
@lxsameer@social.lxsameer.com avatar

I'm going to return to after a very long time. Back then, the hell was excruciating. But now, thanks to , setting up a project is like two seconds from the time you decide to create it to the point you start coding.

kosmikus,
@kosmikus@functional.cafe avatar

@lxsameer Not really dependent on Nix, I'd say. You can use Nix if you want to, sure, but also cabal(-install) itself is much better than it used to be.

haskell,
@haskell@fosstodon.org avatar
terrorjack,
@terrorjack@functional.cafe avatar

@haskell https://gitlab.haskell.org/ghc/ghc/-/issues/24603 for the discussion thread and instructions for reproducing the result

mikwee,

Shoutout to the @haskell team for making such a cool tutorial available on their home page.

haskell,
@haskell@fosstodon.org avatar

@mikwee cheers!

mangoiv,
@mangoiv@functional.cafe avatar

Behold: cursed non-sense that doesn’t work well but is conceivable to work well with a few more minutes (sorry for not putting them in)

https://bin.mangoiv.com/note?id=95b5b823-05fe-4806-ab40-88c35892936a

mangoiv,
@mangoiv@functional.cafe avatar

I think the only thing that needs to be done is to come up with a clever type class that does some flipping for you, based on the arguments. It’s not entirely trivial but might work.

neloj,

I've been trying to make this work for a few days and finally I achieved it, the most basic form of a wayland client using unix sockets, and well in other languages it was not difficult at all, I did it in hare, c, typescript (deno), and in the end I wanted to try with a language that I had never used, Haskell, and I learned many things but I still don't know what a monod is, anyway, here I leave a link to the code for those who are interested: https://gitlab.com/-/snippets/3711372

maralorn,
@maralorn@chaos.social avatar

@neloj This is fracking awesome. Really cool!

Monads are the bane of 's image, they are really not that important, so don’t worry about it.

6d03,
@6d03@mathstodon.xyz avatar

Why is there no MonadFail instance for Either String in the prelude?

The Haskell Unfolder Episode 27: duality (well-typed.com)

"Duality" is the idea that two concepts are "similar but opposite" in some precise sense. The discovery of a duality enables us to use our understanding of one concept to help us understand the dual concept, and vice versa. It is a powerful technique in many disciplines, including computer science. In this episode of the Haskell...

DiazCarrete,
@DiazCarrete@hachyderm.io avatar
mangoiv,
@mangoiv@functional.cafe avatar

this was a lot of fun (named arguments in by using -XOverloadedRecordUpdate)

https://bin.mangoiv.com/note?id=837d3a48-e34e-48e8-b519-8c775f146262

jaror,
jaror avatar

I just saw an old commercial and just had to make this:

https://i.imgur.com/FDwtgtQ.jpeg

kosmikus,
@kosmikus@functional.cafe avatar

Well-Typed is releasing the materials for my video-based intro course to the public, starting today and continuing over the next few weeks. Initially, parts 1 (Introduction) and 2 (Datatypes and Functions) are available.

https://well-typed.com/intro

acowley,

Great to see this effort on improving template ! I think that figuring out why people don’t use quotes more is partly answered by the volume of deficiencies already identified. When you find that a quote doesn’t do something you need, it’s not totally uncommon to switch away from them altogether. https://informal.codes/posts/stabilising-th/

Choreographing a dance with the GHC specializer (Part 2) (well-typed.com)

This is the second of a two-part series of blog posts focused on GHC’s specialization optimization. Part 1 acts as a reference manual documenting exactly how, why, and when specialization works in GHC. In this post, we will finally introduce the new tools and techniques we’ve developed to help us make more precise,...

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

"A strict binding (with a top level !) should not be thought of as a regular pattern binding that happens to have a bang pattern [...] on the LHS. Rather, the top level ! should be considered part of the let-binding, rather than part of the pattern."

I didn't know about this distinction! Found out about it when fiddling with linear let-bindings in GHC 9.10.1.

https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/strict.html#strict-bindings

https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/linear_types.html#bindings

https://www.reddit.com/r/haskell/comments/1d9kexm/comment/l7i5csk/

tristanC,
@tristanC@functional.cafe avatar
mangoiv,
@mangoiv@functional.cafe avatar

Removing the reexports from mtl was, while I really like it conceptually, quite the breaking change, apparently it had become a habit in my team to just import Control.Monad.Except to get access to Control.Monad and Control.Monad.IO.Class… On that note: why’s there no Control.Monad.IO, why do I have to type .Class all the time.

abcdw,
@abcdw@fosstodon.org avatar
tristanC,
@tristanC@functional.cafe avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • haskell
  • DreamBathrooms
  • mdbf
  • osvaldo12
  • magazineikmin
  • cubers
  • rosin
  • thenastyranch
  • Youngstown
  • tacticalgear
  • slotface
  • khanakhh
  • kavyap
  • InstantRegret
  • Durango
  • JUstTest
  • everett
  • ethstaker
  • modclub
  • anitta
  • cisconetworking
  • tester
  • ngwrru68w68
  • GTA5RPClips
  • normalnudes
  • megavids
  • Leos
  • provamag3
  • lostlight
  • All magazines