So after a few days at working with to make bindings to in , I'm actually impressed by it.

It's a tool to help with writing bindings to C library. It can generate a lot of the boilerplate associated with this sort of stuff (e.g., generating wrapper types on the Haskell side) and typechecks the FFI imports by analyzing the C types in the library's headers.

It's not perfect, for instance, I still have one weird problem with the types of some function pointers not being imported correctly. But, while I didn't test anything until I had done everything, I haven't had any segfault or unexpected result with the generated bindings, and I find that pretty impressive!


So now I can make graphs like this and write my equations in !

This is the result of a simulation of the movement of a frictionless pendulum, suspended to a 1 m rod for 10 s. It starts with no velocity at an angle of π/6 with the vertical. The solver returns every 0.1 second. Blue curve is the angle over time, orange curve is the derivative of the angle over time.


More cuuuuurves 

On the previous graph, the curves kind of looked like sine wave because the angles remain small. But, this isn't true anymore for larger angle, as illustrated by the result one gets if the pendulum is released from 3π/4 radian (135 ° from the vertical)

I wanted to explain the code you get in Haskell to write this sort of model, but it's actually quite tricky to explain in a toot^^

Hopefully I'll write a blog post about this when this is more polished

More cuuuuurves 

@typochon I was about to childishly troll you for coming up with a complicated way of plotting the sine function, but you got me bamboozled here

More cuuuuurves 

@otini The small-angle approximation is a lie

Sign in to participate in the conversation
Functional Café

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!