Hacker News new | past | comments | ask | show | jobs | submit login
Interactive constraint solving in Haskell (mattkeeter.com)
113 points by mkeeter on Oct 25, 2015 | hide | past | favorite | 11 comments



Interesting article. It is also possible to resolve constraints probabilistically (i.e. without gradient descent), which is a good approach for functions which are very "unsmooth." I wonder if it is possible to replicate this article using a probabilistic solver (e.g. http://poincare.github.io/DCFL/ - a Haskell probabilistic constraint solving lib. written by me).


I think it'd also be cool to look at more sophisticated deterministic methods with these nice visualizations. I imagine a similar diagram that shows the expansion and contraction of the trust region in an L-M solver would be pretty enlightening as well. Or look at the path taken by steepest descent for pathological cost functions like the Rosenbrock banana.

I've done visualizations like this in Mathematica, which is really awesome for doing interactive visualizations, but it'd be fun to redo these in Haskell. I haven't done much plotting in Haskell, what libraries do people favor?


Cool visualizations, nicely done. By the way there is a typo in the "Constraint Solving" section, in the last equation, it currently is

  c_x - b_y = 1
It should read

  c_x - b_x = 1


Thanks, that's now fixed.


for some reason I get

    "([True,True],fromList [('x',1.7500000780766642),('y',-0.24999969839074443)])"
when i run

    print $ show $ solveSystem 
     [ ((2 * x) + (3 * y)) * (x - y) === 2
     , (3 * x) + y === 5 ] 
     $ Map.fromList [('x', 0),('y', 0)]

which doesn't match the suggested solutions.. using this code: https://gist.github.com/80e982016a267b1f2e48

* edit - lowering the precedence of === fixed it


Thanks, I've updated the page with a fix.


Someone ought to make d3 bindings for ghcjs. It does have an ffi for a reason.


Loving the haskell to javascript thingy. On my i7 4770 animations are still fast.

Although, I thought that animations were done completely in haskell but it seems that necessary functions were exported and data used in d3js.


It's a tiny bit janky on my macbook in Chrome (Canary), and runs like dog on Firefox (Nightly). Not that I care at all - the article is excellent and informative.

But it highlights one of the thing people forget when their language gets a JavaScript compiler: your render target is now the DOM, so you have to start caring/learning about that cross-browser world of pain!


What's with all the Haskell love I've been seeing on HN recently? I kinda feel good about taking that FP course in first year uni now.


Most likely explanation: Baader-Meinhof Phenomenon.

Slightly less likely: modern Haskell distills some ideas that have proven to be beneficial to software projects regardless of the language(s) they choose. As long as the number of HN users grows, and more and more of them realize the benefits of the FP paradigms championed by Haskell, there will be more upvotes for related submissions to the front page.




Consider applying for YC's first-ever Fall batch! Applications are open till Aug 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: