HackerTrans
TopNewTrendsCommentsPastAskShowJobs

pd-andy

no profile record

Submissions

Phantom Types in Gleam

blog.pd-andy.dev
35 points·by pd-andy·vor 5 Jahren·11 comments

comments

pd-andy
·vor 5 Jahren·discuss
Oh yeah I knew I was forgetting one, F#/Fable seems really popular among F# devs, but it doesn't seem like it's picking up any traction for FE devs that aren't already in that community.

Typescript encourages and is generally more conducive to a different style of programming. That's OK (in fact, clearly it's more than OK given its popularity) but it's not really the sort of thing I want to be writing. I think it's worse if you commit to something like fp-ts or the fantasyland stuff, personally.
pd-andy
·vor 5 Jahren·discuss
Lumi: https://twitter.com/hdgarrood/status/1412833319348314121
pd-andy
·vor 5 Jahren·discuss
I think the project is a while off of being properly usable. I think it's mostly written with Node in mind, but shouldn't be too difficult to swap out the Fs bits for browser-specific code.
pd-andy
·vor 5 Jahren·discuss
The compiler written in Haskell relies on some extensions and/or optimisation tricks that make it not possible to compile with GHCJS. The 0.18 compiler (or maybe it was 0.17) was compiled with it though, it was what Ellie (third-party online playground) used.
pd-andy
·vor 5 Jahren·discuss
Neither, really. I'd say it has the largest community out of the various compile-to-js statically typed FP langs, at least with an explicit front-end focus.

- PureScript has a small but passionate community, one of the biggest players in that community laid off their whole ps team so that doesn't bode well.

- ReasonML fractured into ReScript but left half the Reason community behind, it's a confusing space to navigate now.

- GHCJS...

Most (perhaps even all) of the job postings end up on the elm slack (rather than, say, reddit or other more visible places).

There was some controversy with the release of 0.19 a couple of years ago, and general contempt (in the wider community, not inside Elm) for the way the language is developed and run which means there isn't a great deal of buzz about it outside of those already using it.
pd-andy
·vor 5 Jahren·discuss
Ha yes, very true!
pd-andy
·vor 5 Jahren·discuss
As far as I know those two are equivalent. Definitely slightly clunkier, but is what it is.
pd-andy
·vor 5 Jahren·discuss
Not quite. I guess in some ways phantom types achieve the opposite of structural typing.

In a language with structural typing, two types are considered equivalent if they share the same structure. With phantom types we can have a single structure and disambiguate between different uses without touching the underling structure. There's no difference between Id(User) and Id(Post) at runtime, the annotation is purely a compile-time restraint.

In fact, because of typescript's structural typing, the only way to use phantom types in ts is to have some dummy field of type `never` that the type system can use to disambiguate between the two [1].

[1]: https://gist.github.com/GoNZooo/243b23702df1fae38c966ae18832...
pd-andy
·vor 5 Jahren·discuss
Using phantom types in state machine transitions is really cool, yeah. I came across a little gist that explored that idea in Elm [1] the other day, actually.

[1]: https://gist.github.com/rupertlssmith/88946c8d207d7ad64daf43...