ski 2017-03-05 20:00:25
catchError :: StateT s (ExceptT e m) a -> (e -> StateT s (ExceptT e m) a) -> StateT s (ExceptT e m) a
ski 2017-03-05 20:00:29
becomes
ski 2017-03-05 20:00:55
catchError :: (s -> m (Either e (a, s))) -> (e -> s -> m (Either e (a, s))) -> s -> m (Either e (a, s))
ski 2017-03-05 20:01:41
as with `(>>=)', we start by passing the initial state (third argument) to the first argument, getting `m (Either e (a, s))', executing it as an `m'-action (using `(>>=)' for `m') to get `Either e (a, s)'
ski 2017-03-05 20:02:39
if we have `Right' here, we just use `return' to forward this as a result of executing the action made by calling `catchError'
ski 2017-03-05 20:02:58
but if we have `Left', we need now to call `e -> s -> m (Either e (a, s))' with this `e', and an `s'
ski 2017-03-05 20:03:05
but *which* `s' ?
ski 2017-03-05 20:03:37
the first argument, `StateT s (ExceptT e m)', aka `s -> m (Either e (a, s))' has quite possibly computed intermediate states of type `s' internally ..
ski 2017-03-05 20:03:47
.. but there's no way to get at those from this vantage point
ski 2017-03-05 20:03:53
all we have as result is an `e'
ski 2017-03-05 20:04:35
the only `s' we could continue the exception handler `e -> StateT s (ExceptT e m) a', iow `e -> s -> m (Either e (a, s))' with is the initial `s' `catchError', which was fed to the first argument
ski 2017-03-05 20:05:03
i.e. we *roll-back* the state to what it was when entering the exception-catching construct !
ski 2017-03-05 20:05:24
hololeap : makes any sense ?
hololeap 2017-03-05 20:18:16
ski is from the u.k.? :) i have never heard of dexter/sinister before, but it apparently has to do with a coat of arms
ski 2017-03-05 20:18:32
"sinister" and "dexter" is latin for "left" and "right"
hololeap 2017-03-05 20:18:57
is this commonly used in C.S.?
ski 2017-03-05 20:19:04
not that i know :)
hololeap 2017-03-05 20:19:19
lol, ok then.
ski 2017-03-05 20:19:52
just trying to make use of preexisting association between "left" and "bad", respectively "right" and "good"
hololeap 2017-03-05 20:20:07
ok, i understand
hololeap 2017-03-05 20:20:40
in other words, abstracting from left/right which don't mean much in this context
ski 2017-03-05 20:21:53
(that in turn presumably comes from when humans started farming, and had to make handed tools, and (simplifying the explanation) so to not have to make both left and right handed tools, only make ones of one kind, which happened to be ones which are most comfortable to use with right hand. as a result, right-handed people survived better)
zipper 2017-03-05 20:24:18
ski: Thankee
ski 2017-03-05 20:25:03
zipper : fwiw, i also use form feeds .. and indent the body of a module :)
maybefbi 2017-03-05 20:25:30
on one hand we have recursion schemers, insisting that recurring part of the type be parametrized so that Fix can hide in there. but on the other hand, libraries like Data.Tree or any recursive type not parametrizing the recursive part of the tree. why is it this way?
ski 2017-03-05 20:26:16
`Fix' is unfortunately a bit awkward to use ..
maybefbi 2017-03-05 20:26:27
hmm yeah
maybefbi 2017-03-05 20:27:15
i guess then recusive schemes will remain an oddity
ski 2017-03-05 20:27:15
(also, `Fix F' doesn't determine `F', meaning that there can be many different ways of, given a type `T', specifying a type `F' such that `T' is iso to `Fix F')
zipper 2017-03-05 20:27:49
ski: You indent the body of a module? Like all your code is indented?
ski 2017-03-05 20:28:02
e.g., given `T' a binary tree, you could choose to have `F' only abstract over right sub-trees
zipper 2017-03-05 20:28:04
You can't be serious.
zipper 2017-03-05 20:28:07
Show me an example ski
ski 2017-03-05 20:28:15
or have `F' correspond to two layers of a tree, not one
hololeap 2017-03-05 20:28:55
ski: i wonder if the fact that the heart is on the left has anything to do with that
hololeap 2017-03-05 20:29:15
or vice-versa
hololeap 2017-03-05 20:29:44
*the fact that the heart is on the left *in most people*
maybefbi 2017-03-05 20:31:50
ski, ok
mniip 2017-03-05 20:41:42
piyush-kurur, ffi calls cdecl-declared functions
mniip 2017-03-05 20:41:56
or well, maybe some other calling convention
mniip 2017-03-05 20:42:05
depending on your OS, system calls might or might not be that
piyush-kurur 2017-03-05 20:42:20
mniip: thanks.
mniip 2017-03-05 20:42:28
depending on platform details, even, (think vdso/vsyscall)
piyush-kurur 2017-03-05 20:45:18
I think then it is safer to just wrap it in c.