Announcing `crem`

I would like to announce the first release of crem

crem stands for compositional representable executable machines.

It allows defining state machines (Mealy machines in fact), composing them to build bigger machines out of smaller ones and then running them and drawing their flow and their state space.

The repository contains extensive documentation and several examples, including domain modelling with state machines and a terminal-base adventure game.

Please check it out and let me know how it could be improved

22 Likes

A+ for the Mermaid rendering, you should advertise this more. :slight_smile:

4 Likes

State machines don’t get the love they should, this is awesome. I will rewrite and formalize some internal state machines used on an app I wrote.

1 Like

Hi! Nice! Please let me know if you encounter any issue or even any suboptimal thing

1 Like

Do you have any comparison against machines?
Good to see another approach to state machines.
Type safe state transitions are a nice feature (for example hobbitTopology).

2 Likes

I am no machines expert, but I’ll try to provide some thoughts:

  • machines focus appears more to be on creating a streaming library, like pipes or conduit, and it happens to use state machines. crem on the other is (at least for now) only a state machine library. Maybe it would be possible to provide a AutomatonT instance for crem StateMachineT type, so that you can then use crem state machines inside the machines framework.
  • machines Machines are demand driven (I guess this means that they will proceed in their evaluation only if there is request of another output), while crem StateMachine will execute until it is finished.
  • crem focuses more on type safety and the ability to create a graphical representation out of a state machine
  • I haven’t tested performance-wise. I guess compilation times could be higher for crem but I expect run times to be similar
4 Likes

I reached for this yesterday and found that it didn’t compile with 9.10. So I rolled up my sleeves and updated it with new version bounds. I was about to submit a pull request but I didn’t know how to handle the literate Haskell doctest part.

Here’s my update so far:

And here’s where I immediately put it to work on my backend API where it prevents illegal state changes at the type level along with additions to my tests to verify the veracity of that claim: https://github.com/harryprayiv/cheeblr/tree/alpha/backend

Thanks for your brilliant work. I feel that I’m finally reaching the point in my journey where I’m starting to understand why so many are anxiously awaiting dependent types.

2 Likes

This is nice! I like the simplicity combined with type safety, I could imagine trying to apply this for domain modelling as a more formalised diagramming, besides the fact it could be executed.

1 Like

Nice! I’ll try to take a look at your work and see if I can make it compile for the whole project.

It’s awesome that you’re using crem for your project. Is it something that you plan to use in production?

1 Like

yes! I initially created the library to try to fill the gap between a drawing of the design and its implementation.

If you want the original repository contains several examples (crem/examples/Crem/Example at main · marcosh/crem · GitHub) from really simple to more complex ones

1 Like

It definitely feels clunky compared to dependent types but it’s REALLY cool and futuristic for this ecosystem.

Absolutely! I had been hesitant for a while. Then, I was thinking about the guarantees that CREM could offer me and decided to use it. Thanks again for your brilliant work.

1 Like

The work I did got me like 99% of the whole module compiling. So, your work on an update is going to be really easy. I was about to submit a pull request but I hesitated because of that doctests literate Haskell part that confused me a bit. If you want, I can submit a pull request to get you most of the way there.

Also, I didn’t quite get around to adding the upper boundaries back into the cabal file. So, without those, I imagine it could break pretty easily until you put those in (or a cabal freeze).

1 Like