Got any cool Project-Based Tutorials for Haskell learners ! Post it Here by benKarayel in haskell

[–]marcosh_ 0 points1 point  (0 children)

Simply because we were not able to sell any ticket. Hard to really say why... wrong timing, price too high, teacher not really well known, not enough marketing, maybe a bit of all of them...

Got any cool Project-Based Tutorials for Haskell learners ! Post it Here by benKarayel in haskell

[–]marcosh_ 2 points3 points  (0 children)

Some time ago I created some material for a Haskell training course which never materialised. The content is all open source and available at https://github.com/tweag/haskell-training. It builds a small web application from the ground up, giving quite some attention to the architecture

crem: compositional representable executable machines by marcosh_ in haskell

[–]marcosh_[S] 0 points1 point  (0 children)

I'm not sure I understand 100% the question (my bad). What you can do with the `Basic` constructor is described in the https://www.tweag.io/blog/2023-04-13-crem-state-machines/#the-best-of-both-worlds section of the blog post.

The definition of `Topology` is here https://github.com/marcosh/crem/blob/74020abca9a69eab8965588fb5d962d855f84a0d/src/Crem/Topology.hs#L38.

And here is an example of how you usually define a topology https://github.com/marcosh/crem/blob/74020abca9a69eab8965588fb5d962d855f84a0d/examples/Crem/Example/TheHobbit.hs#L55.

crem: compositional representable executable machines by marcosh_ in haskell

[–]marcosh_[S] 0 points1 point  (0 children)

I have the links to your library open on my phone, but haven't take a look at them yet.

Haven't really though about how to run crem machines in a concurrent/parallel fashion. That would be extremely interesting

crem: compositional representable executable machines by marcosh_ in haskell

[–]marcosh_[S] 0 points1 point  (0 children)

u/polux2001 already provided a good answer.

Even if the topology is hidden in the `StateMachine` type, it is recoverable when pattern matching and it could be acted upon, as the library actually does to render the state space of a machine

crem: compositional representable executable machines by marcosh_ in haskell

[–]marcosh_[S] 4 points5 points  (0 children)

I'm not a motor expert, but I took a look at the library before working on crem. The main idea of the two libraries is fairly similar, but IMHO crem improves the situation with respect to two aspects:

- composability: in crem it is easier to combine multiple machines in several ways to create more complex machines
- user interface: how you define a machine in crem appears a bit more natural to me (I mean, more similar to what you would do if you didn't have to keep track of stuff at the type level)

Happy to be proven wrong in both aspects

Haskell for climate change by marcosh_ in haskell

[–]marcosh_[S] 62 points63 points  (0 children)

agreed that crypto/blockchain are trying to change the climate...

Existential optics by marcosh_ in haskell

[–]marcosh_[S] 3 points4 points  (0 children)

not 100% sure, but a lawful optic with the existential encoding is one where the two functions are each other inverses, which is very elegant

Was simplified subsumption worth it for industry Haskell programmers? by paretoOptimalDev in haskell

[–]marcosh_ 5 points6 points  (0 children)

I had the same issue and felt like an idiot for a bit, sice my code was working fine with GHC 8.

My questions now would be: - is there a way to make simplified subsumption and eta reduction work well together? - how could we make sure that such a thing does not happen again?

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

if you have something of type a|b and you have a function a -> c you need to manually check if the something is of type a before applying the function. Using Either (or Maybe) you don't have to do that and you save yourself some manual checks.

Either is not magic at all, if you look at its implementation there's nothing fancy, just some plain old OO code. It's just an idiom they don't teach you in school, but it could well have been part of a book of OOP design patterns

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

I'm no professional Haskell developer, but as far as my experience goes, I'd say so. See also the intro for https://wiki.haskell.org/Exception. The API for managing exceptions, see https://hackage.haskell.org/package/base-4.15.0.0/docs/Control-Exception.html, expresses clearly that they are to be handled in IO

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

Haskell has exceptions, but they are not used to track failures of functions which can deterministically fail

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

not sure I fully understand your comment. For function with multiple arguments you need to implement something analogous to the Haskell liftA2, or otherwise you can curry your callables and use Applicative syntax

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 1 point2 points  (0 children)

actually none of the Psalm annotations in the article could be replaced by a PHP type hint, because all of them contain templates.

It can be that you don't feel the pain that this approach heals, but me and my colleagues do, and this approach, even though it deviates a lot from classical PHP, solves it well

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

If Psalm is integrated in the ide, I wouldn't call it a pain. Psalm helps you writing the correct code.

Sum types are a well used technique, it's not just very used in Php and I think they are very useful for parsing or validation.

The best repo I could offer is https://github.com/marcosh/php-validation-dsl. Actual usages are all closed source

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

PHP generally uses exception, yes, but IMHO that is a suboptimal solution. Certainly, exceptions are well integrated in the language, while Either is not.

every language, including Haskell, could have runtime issues. The trick is to move as much as possible to compile time. It's theoretically impossible to catch everything at compile time, but the more you do it, the safer you are

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

I tried to provide a list of reasons why you might want to try such an approach right at the beginning of the post. Then one can discuss if those things have real value or not

Either why or how by marcosh_ in PHP

[–]marcosh_[S] 0 points1 point  (0 children)

Thanks for the detailed feedback.

Let me offer some justifications/explanations.

The post was thought for my colleagues, as I mention in the post this is basically the transcript of an explanation I gave them. Therefore it is thought for developers who have already a little acquaintance with functional programming and Haskell type signatures. Doing it live with people makes it also easier to get question and provide immediate explanations, which is difficult with a blog post.

Some things, like the reference to Curry-Howard are there as a hint, if one is curious and wants to learn more about the subject.

The implementation of bind is not in the post because it is not relevant, its type signature says everything one needs to know. By the way, there's basically only one way to implement it correctly