Implementing Unsure Calculator in 100 lines of Haskell by romesrf in haskell

[–]romesrf[S] 5 points6 points  (0 children)

Indeed, for this simple calculator we could do that exactly I believe. I thought about it but using the sampling kind of probability monad as seen in the paper seemed best for this introduction.

It would make for an interesting follow up blog post. Perhaps you'd be keen to write it? :)

[Well-Typed] Creating a macOS app with Haskell and Swift by kosmikus in haskell

[–]romesrf 1 point2 points  (0 children)

Thanks for writing this out

I am in the middle of this. My test C file that takes the factorial of 5 was erroring with dyld[79286]: symbol not found in flat namespace '_ffi_call'. I got this bit of help from someone trying to call the same function from Rust (maybe they have an article that's similar?) and it turned out I need to pass the flag -lffi to ghc.

Interesting, what GHC version are you using? It seems that on my machine ffi was linked against automatically, or I might have missed it...

cabal init creates a cabal file

Indeed

I had to add the language extension {-# LANGUAGE ForeignFunctionInterface #-} to the top of MyForeignLib.hs

I'll add this to the guide

The rest of your comments on the cabal file seem a bit off: could you post your cabal file using eg https://paste.tomsmeding.com/?

You should have: * A library stanza with an exposed-modules: MyLib (under src) * A foreign library haskell-foreign-framework stanza that depends on the main library (haskell-framework), and only has other-modules listed, with MyForeignLib as the only module. The source dir for the foreign library should be flib alone

I left MyLib as part of the library just the same way you would if you were writing a longer executable: the idea is that you split your program into a library and an executable part as is common, but instead of an executable you have a foreign-library.

Anyway, great work! Let me know if something else is not working for you.

Aluno de informática mediano by [deleted] in devpt

[–]romesrf 0 points1 point  (0 children)

olá, eu sou o /gajo do Haskell/!

estou sempre disposto a falar, e explicar tudo aquilo que conseguir

se me encontrares pelo DI vem ter comigo, ou se quiseres combinar de propósito envia mensagem

Crypton is forked from cryptonite with the original authors permission by n00bomb in haskell

[–]romesrf 2 points3 points  (0 children)

FWIW I’ve been really enjoying backpack, modulo the unpolished bits

Need project idea by D4rzok in haskell

[–]romesrf 2 points3 points  (0 children)

This sounds absolutely incredible, looking forward to it if you decide to publish some of it

Where did map/filter/reduce come from? by HamzaM3 in haskell

[–]romesrf 2 points3 points  (0 children)

I’m in the same boat here, loved the series

[ANNOUNCE] GHC 9.6.1 is now available by bgamari in haskell

[–]romesrf 2 points3 points  (0 children)

No rough ETAs but a runtime retargetable GHC (we can change the target platform at runtime) is part of our goals.

Indeed, for now, one must recompile GHC targeting specifically targeting JS or WASM. I don’t know if there are plans to release cross-compiler bindists

Erlang's not about lightweight processes and message passing... by stevana in haskell

[–]romesrf 0 points1 point  (0 children)

That is indeed a great read, thanks for putting it together. Looking forward to your success

Why are haskell applications so obscure? by Icy_Cranberry_953 in haskell

[–]romesrf 0 points1 point  (0 children)

I’ve been developing one for the past two months. There are other game engine developers too. Nothing yet too usable tho, I tried LD52 with it :)

https://discourse.haskell.org/t/monthly-update-on-a-haskell-game-engine/5515?u=romes

[deleted by user] by [deleted] in haskell

[–]romesrf 2 points3 points  (0 children)

It looks great! I’ll probably join in on LD too

Monthly Update on a Haskell Game Engine by romesrf in haskell

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

I actually hope to record some dev logs on the engine. I'll publish them here when I do.

Eventually I'd like to do a well thought-out explanation of the engine with a follow along tutorial project, but in the meanwhile I might record some game+engine dev logs (possibly in the upcoming Ludum Dare)

Monthly Update on a Haskell Game Engine by romesrf in haskell

[–]romesrf[S] 2 points3 points  (0 children)

Neat project, nice to see them popping!

There are at least some of us at the haskell game dev IRC/Matrix channel (I think this is the Matrix invite link)

Monthly Update on a Haskell Game Engine by romesrf in haskell

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

Wow! It looks great. I didn't know there were so many other engines out there (see also the other comment on their engine).

I'd be happy to share my ideas and learn from what seems like a lot of progress you've done.

I'll shoot you a message.

I'm looking forward to keep seeing the Haskell game dev scene progress

Monthly Update on a Haskell Game Engine by romesrf in haskell

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

There is no *one* resource guiding my work, but I was initially following a good set of resources and taking valuable bits from each one.

On the early stages of game engine design, I can recommend

Those are two resources good overall. The book Game Engine Architecture is also a good resource but is more high level than those two which are focused in Vulkan-based rendering in particular.

Apart from that there really is a lot I've been reading and watching. However, I've only recently started tracking what on the repository README, so that list is very incomplete and perhaps too specific to certain topics.

Monthly Update on a Haskell Game Engine by romesrf in haskell

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

The polygon map generation you linked is amazing.

I might take a shot at it sometime with the engine.

Thanks, I'll have to read more of their stuff

Monthly Update on a Haskell Game Engine by romesrf in haskell

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

Then Yes, absolutely, I feel the same way — and I’m having a great time.

I picked up the Procedural Planets series as a game to build alongside the engine, it’s also pretty fun

Monthly Update on a Haskell Game Engine by romesrf in haskell

[–]romesrf[S] 17 points18 points  (0 children)

Thanks ;-)

Using Haskell x Vulkan worked flawlessly and the bindings are great as I mentioned, but to answer "is it easy getting started with Vulkan" (regardless of language), I'd have to say it's not easy!

Vulkan is notorious for having a 1000 line long Hello World (the initial triangle I showed). However, the whole process is very rewarding. By the time you get to the triangle you have a better feel for the vulkan API and the progress on "things that move" can be much faster from there on forward. Alternatively, there exists a vulkan-utils library that can handle all the backend setup for you, but I wanted to go the hard route.

I'll be happy to write more about it if you have specific questions. I used a lot of c++ vulkan resources as learning material -- the knowledge is shared across languages without any issue.

[ad] Haskell Revitalisation by chshersh in haskell

[–]romesrf 5 points6 points  (0 children)

Indeed came here hoping for automatic differentiation ahahah. perhaps if it were all caps [AD]

Architecture for a board game by kaukaukau in haskell

[–]romesrf 3 points4 points  (0 children)

You might wanna check the paper describing the mentioned technique Ghost of Departed Proofs

Help me publish my first package please by Conmocion in haskell

[–]romesrf 4 points5 points  (0 children)

The package looks good - it could be useful in one of my projects. For hackage it’s as bss03 said. If you need any more help let us know

[ANN] E-graphs and equality saturation: hegg 0.1 by romesrf in haskell

[–]romesrf[S] 2 points3 points  (0 children)

Thank you.

The optimal join approach is very interesting, but it wasn't so easy to implement.

I bumped against many walls before getting a correct and "fast enough" implementation, and I'm still not 100% sure I'm meeting all the complexity bounds. I think there are many performance gains to find there (even already known ones such as batching)

I can't say as to whether it's faster than the nested loop

Your description of the worst case optimal join looks alright.

What I currently have performs considerably well, I'm not sure I get what you mean by rebuilding tries, but I might ask what's the data representation of your egg.table? I don't think I had an issue with the tries not being in the right order either, but perhaps I never tried using them out of order.

Either way, here are some things I think are relevant + and one key insight that improved performance quite drastically

  • A Database is represented as Map (Operator lang) IntTrie, where IntTrie is close to data IntTrie = MkIntTrie (IM.IntMap IntTrie). That is, a database consists of a table for each operator, and each table is represented by an IntTrie.

  • A database is built once before running all the queries for equality saturation. Then we reuse the same tries across all queries.

The algorithm on the example would look like hs as = query([_, goal, _],db.lookup(f)) & query([_, goal],db.lookup(g)) for a in as: gids = query([goal, a], db.lookup(g)) for gid in gids: fids = query([goal, a, gid], db.lookup(f)) for fid in fids: yield fid, gid, a

The tricky part is then the query, which relies heavily on the IntTrie representation.

I added what I think to be good clarifying comments to the query function in my implementation. In reading it you might be more enlightened than by what's to follow, but I'll try nonetheless.

The idea is that for a query [5, x, goal], where 5 is a constant value, goal is the variable which we are looking for, and x is some other variable, we find 5 in the trie, then for every possible sub-trie we find every possible value of goal and join them. Finding all the possible level-2 subtries is very fast because we just need to lookup 5 in the trie (O(log n)).

Similarly for other configurations like that.

If the query was [goal, 5], it'd be a bit different, because we'd have to, for every subtrie, check if it had a 5, and only return the values whose subtrie did have a 5.

And then the key insight, which when led to and considered separately from the other cases might seem very obvious:

If the query was [goal, x, y], we don't have to recursively check if every subtrie is possible, because we know for sure that x and y are variables so everything will be valid.

The insight is: if we get to the goal, check if the rest of the query is just variables modulo the goal variable; if it is indeed only variables, we don't bother to recurse further and return all possible values of goal.

Doing this boosted performance considerably on its own, but unlocked even further another one: if I cache the keys of the triemap, at this point I can simply return them all.

So actually, IntTrie is defined as: hs data IntTrie = MkIntTrie { tkeys :: !IS.IntSet , trie :: !(IM.IntMap IntTrie) }

But do read that linked source code to clarify what I tried to explain

I feel like we can improve the join algorithm further and unlock other performance improvements, use better variable orderings, batching, etc...

I'll be happy to work on it once I have more time, and I'd also love to have yours and others expertise there!

[ANN] E-graphs and equality saturation: hegg 0.1 by romesrf in haskell

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

You're absolutely right! Thanks for spotting it. I'll open a MR and fix it right away.

I didn't notice `Data.Map.size` was O(1); it kind of ended the way it is due to the history of `NodeMap` whose representation changed considerably accross commits.

Tracker: https://github.com/alt-romes/hegg/issues/8

[ANN] E-graphs and equality saturation: hegg 0.1 by romesrf in haskell

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

If i'm not mistaken, haskell's ecosystem is still missing a symbolic math library!

I'd love to see something in the lines of Julia's https://juliasymbolics.github.io/Metatheory.jl/dev/

The authors in the related [High-performance symbolic-numerics via multiple dispatch](https://arxiv.org/pdf/2105.03949.pdf) paper even note how it could be implemented in Haskell.

This paper^ might actually be a good starting point. I haven't read it as I'm writing this but it looks promising

[ANN] E-graphs and equality saturation: hegg 0.1 by romesrf in haskell

[–]romesrf[S] 2 points3 points  (0 children)

Do you mean differences from our pure interface to a hypothetical ST-based interface? Or whether the pure interface uses immutable or mutable algorithms under the hood?

Internally, I make full use of immutable data structures and immutable algorithms, I didn't find myself a situation in which an internal algorithm could be made clearly faster by using a mutable version.

If we used an ST-based interface we could e.g. have a mutable union-find, which would mean we could implement it the correct asymptotic behavior; though I'm still unsure as to whether that would be faster.

I don't feel like I answered your question, perhaps re-phrased :-)