They can, the effect modeled by the list monad is non-determinism.
303 karma · joined June 30, 2014
They can, the effect modeled by the list monad is non-determinism.
Yes, Maybe/Options are a way of encoding partial functions/exceptions.
List is a way of encoding non-determinism.
Effects are encoded using a polymorphic type with a `map` operation (called a functor), and effectful computations are functions `a -> E b` for some types `a, b` and effect `E`.
A monad is exactly the plumbing you need for composing effectful computations: it turns a computation `b -> E c` into a `E b -> E c` so that you can compose `a -> E b` with `E b -> E c` to get a composed computation `a -> E c`.
It does so in a way that makes effectful composition associative (i.e. the way you'd expect)
I thought Scala had an even stricter value restriction than ML, where only function/methods may get a polymorphic type?
type Tree a = Fix (TreeF a)
so that `toTreeF` is just `unfix` (and is effectively free, as I mentioned above)Suppose you have a recursive `tree` data structure, and another one `tree' x` where `tree' x` is just like `tree`, but with recursive occurrences of `tree` replaced with type x. So maybe something like, in Haskell-ish syntax:
type tree = Leaf int | Node tree tree
type tree' x = Leaf int | Node x x
Then one can easily write a `fold` over trees with type fold: tree -> (tree' x -> x) -> x
where the second parameter (called an algebra) evaluates the result over a tree' assuming recursive subtrees have been replaced with the result of their evaluation (this is the key).Now the beauty of recursion schemes is that whenever `tree'` is a functor, you can get `tree` (as a fixpoint: `tree = tree' tree`) and `fold` for free (generally called `cata`), which can be seen by rewriting `fold` above using just `map`.
This skips a fair amount of boilerplate code you no longer have to touch when modifying recursive types.
Is it possible to church-encode these with Go generics?
with context() as foo:
leak = foo
This is unlike list comprehensions, where it is syntactically impossible to bind the comprehension variable to a new name accessible outside the comprehension.So maybe the reason is that it is not really worth the trouble.
IIRC python3 fixed scope leaks in list comprehensions, does anyone know why they didn't fix this one as well? Or does it have actual uses in practice?
# mypy: disallow-untyped-defs
on top of new python files.Again, using 3 quaternions and uniform weights with the above algorithm gives slerp(slerp(a, b, 1/2), c, 1/3) but medians in a spherical triangle don't cross at 2:1 ratio in general.
It works when doing LERPs (linear interpolations) but the algorithm above uses SLERPs (spherical interpolations) which can be expressed with quaternion products/exponentials/logarithms, so I think the order does matter.
A quick numerical check with 3 quaternions and uniform weights seems to confirm this.
I think that's the idea.
> I mean, what does all this buy you that applying a subset of affine transformations (scaling, translation, rotation) to an orthogonal coordinate system doesn't give you already?
Well, algebra: with the geometric product one can solve geometric equations in a nice, unified way.
The Wikipedia page[1] mentions the issue briefly but I was curious of the counter-examples. IIUC, matrices in SL(2) with trace < -2 have two distinct eigenvalues, one of which is negative[2], and such matrices cannot be reached by exponentiating elements of the Lie algebra sl(2) (traceless matrices).
[1] https://en.wikipedia.org/wiki/Exponential_map_(Lie_theory)#S...
[2] https://en.wikipedia.org/wiki/SL2(R)#Classification_of_eleme...
A tangent vector x at the identity is split in n chunks, each chunk is added to the identity to get a matrix (I + x / n). Each of these matrices gets increasingly closer to the group as n increases, and these n matrices are composed together to approximate exp(x), in a similar fashion to forward Euler integration with n iterations and integration step 1/n.
The actual formula ends up being the usual power series and is useful for computations, but I find the limit above really captures the essence of how the exponential works.
I think that's the key, thanks.
But still, if some inputs are redundant shouldn't this be somehow apparent in the eigen-vectors/values of the covariance matrix (making PCA an indirect feature selection algorithm)?
This wouldn't solve the performance issue, but at least it would provide a nice abstraction for protocols.
You can't really pass around functions freely like you would in Haskell/ML unless you start Box-ing/Rc-ing everything. But then it's not really idiomatic Rust anymore, IIUC.
I was curious too, but my google-fu did not succeed. The closest I found is about printf being Turing-complete [1], which is also new to me.
My impression is that if you want something compact that you'll need to either give up on performance (type erasure) or separate compilation (track every type).
GA is great for pen and paper proofs though.
No really, unit quaternions are nice because it's pretty clear they belong to a sphere, therefore you can fairly easily extend geometric methods on the usual sphere to perform filtering, averaging, interpolation etc on rotations.
With GA it's not so obvious.
How do people handle repetitive patterns in practice? By extending Meson itself?
[0]: https://github.com/mesonbuild/meson/issues/3234
[1]: https://mesonbuild.com/FAQ.html#why-doesnt-meson-have-user-d...