ski 2017-02-03 06:45:18
Forty-Bot : you have various redundant brackets .. `(showsInfixPrec, )' could be `(showsInfixPrec)', `(Show a) => ' could be `Show a =>', `(-:) a b' could be `a -: b', `(+) (Cons a b) (Cons c d)' could be `Cons a b + Cons c d', `((b * c - a * d)/(c ^ 2)' could be `((b * c - a * d) / c ^ 2', `(fromRational' c) * b' could be `fromRational' c * b'
ski 2017-02-03 06:45:30
Forty-Bot : is `infixr 8 ^/' (or higher) ? if so `b * (a ^/ (c - 1))' could be `b * a ^/ (c - 1)', `b * (exp a)' could be `b * exp a', `b * (negate $ sin a) could be `b * negate (sin a)', `one + (a ^ 2)' could be `one + a ^ 2'
ski 2017-02-03 06:46:10
Forty-Bot : sometimes you use `Cons', sometimes `+:' in expressions .. is there any rhyme or reason to when you pick one over the other ?
Forty-Bot 2017-02-03 06:46:41
I remember trying to replace all the Cons with +: at one point and getting errors
Forty-Bot 2017-02-03 06:46:45
so I reverted it
Forty-Bot 2017-02-03 06:47:00
I think it only complains about the cons on the left side
ski 2017-02-03 06:47:09
(Forty-Bot : i refrained from mentioning some stuff that were similar to other stuff i already mentioned. you should be able to find them, and consider whether you want to change them)
hrk 2017-02-03 06:49:44
@pl \x y -> sum $ zipWith f x y
lambdabot 2017-02-03 06:49:44
(sum .) . zipWith f
ski 2017-02-03 06:50:34
Forty-Bot : yes, you can't match on `+:', unless you make it a pattern synonym, see
ski 2017-02-03 06:51:06
.. hm, i wonder whether pattern synonyms can be infix ? i suspect they will have to start with a `:' in that case (so you'd have to rename to `:+:', say)
Forty-Bot 2017-02-03 06:51:28
from hackage.haskell.org/package/numeric-prelude-0.4.2/docs/Algebra-Algebraic.html it appears ^/ is infixr 8
ski 2017-02-03 06:51:44
Forty-Bot : sorry, forgot `deriving (Eq)' could be just `deriving Eq'
ski 2017-02-03 06:52:02
.. and in that case, possibly it's simpler to just use `data T a = (:+:) { real :: !a, nonreal :: !a } deriving Eq' ?
ski 2017-02-03 06:52:24
Forty-Bot : i suspected so, since `^' is `infixr 8'
Forty-Bot 2017-02-03 06:52:28
are there any naming conventions for infixes?
ski 2017-02-03 06:52:50
presumably this `*' is still `infixl 7', so then `b * a ^/ (c - 1)' will parse as you want
cocreature 2017-02-03 06:53:12
spatial: there is an official spock tutorial, have you looked at that? https://www.spock.li/tutorial/
ski 2017-02-03 06:53:21
it's common to use a "symmetric symbol" for commutative operations
Forty-Bot 2017-02-03 06:53:47
this isn't really commutative, though
Forty-Bot 2017-02-03 06:54:03
because you get a different value for a +: b as b +: a
ski 2017-02-03 06:54:28
maybe `:+|' or something ..
Rodenbach 2017-02-03 06:54:42
Anyone here who has many years professional experience with Haskell AND Clojure?
phadej 2017-02-03 06:55:18
just askk your question :)
Rodenbach 2017-02-03 06:56:11
I don't have a specific question, but want to talk to this person (in private).
ski 2017-02-03 06:56:56
(sometimes not directly commutative, e.g. `(++)' (with `reverse (xs ++ ys) = reverse ys ++ reverse xs', so "commutative upto distributing `reverse'", probably that can be stated in another way ?),`(<*>) :: Applicative i => i a -> i b -> i (a,b)' (here (depending on `i'), you may get the same if you commute as if you swap the pair)
ski 2017-02-03 06:58:53
Forty-Bot : are you sure `todual' (`toDual' ?) shouldn't use `zero' instead ?
Forty-Bot 2017-02-03 06:59:41
ski: well, I found myself wanting a function to convert
ski 2017-02-03 06:59:49
Forty-Bot : looks like your `deriv' could avoid matching on the `T a', and also use `toDual' (assuming it was meant to use `zero')
Forty-Bot 2017-02-03 06:59:50
when I was graphing derivatives
Forty-Bot 2017-02-03 07:00:23
and it has to be one or else the value gets treated like a constant
Forty-Bot 2017-02-03 07:00:33
and you don't get a derivative from it
ski 2017-02-03 07:00:50
Forty-Bot : shouldn't `toDual zero = zero' and `toDual one = one' hold ? they can't if `toDual' uses `one' like that, while `one' and `zero' uses `zero' in the infinitesimal component
Forty-Bot 2017-02-03 07:01:21
hm
Forty-Bot 2017-02-03 07:01:39
maybe I could use asconst and asvar
ski 2017-02-03 07:03:09
Forty-Bot : yeah, but i thought `toDual' was meant to include the plain ring elements as constants ? and anyway, `deriv' doesn't currently use `toDual' ..
ski 2017-02-03 07:04:07
`asVar' could be constructed with multiplication (or scaling) with `one +: one', which possibly should get a name (`identity' ? `time' ?)
Forty-Bot 2017-02-03 07:04:23
ok, I think that makes sense
Forty-Bot 2017-02-03 07:05:21
as for deriv, somehow I need to get f to apply on a T (T a)
Forty-Bot 2017-02-03 07:05:32
so it will calculate the 2nd derivative
noan 2017-02-03 07:08:38
I did it mommy, I made haskell respond to a POST request from my game project. Day is good. That is all.
runeks 2017-02-03 07:09:10
So, if I allocate a resource using Control.Monad.Trans.Resource.allocate, how do I either never call the release action or change what the release action is? I'm beginning a transaction using `allocate`, and setting the release action to "rollback tx", but I only want this to fire if something goes wrong, otherwise I want to do "commit tx".
runeks 2017-02-03 07:09:58
"unprotect" returns a cleanup action, too, so I'm not quite sure if I should be using this
runeks 2017-02-03 07:10:43
Is "unprotect" giving me back the release action registered using "allocate", thus allowing me to just no run it?
runeks 2017-02-03 07:10:59
*just not run it
ski 2017-02-03 07:12:14
Forty-Bot : btw, are you aware of Automatic Differentiation, ? there's a package by edwardk. you could also check "Functional Differentiation of Computer Programs" by Jerzy Karczmarczuk in 2000-09-15 at (you could also take a look at "Adjoint Codes in Functional Framework" if you like the other one)
Forty-Bot 2017-02-03 07:12:49
ski: yeah, but this is more for myself than anything else :P
ski 2017-02-03 07:13:17
i thought the Karczmarczuk paper was neat, when i first found it
ski 2017-02-03 07:20:38
Forty-Bot : it is (or at least was) possible to add a context on a data type, like your `T', but it didn't do what people expected, so we usually advice away from it. if you really want it, use GADT syntax when defining the type, and add the constraint(s) on the data constructor(s)
ski 2017-02-03 07:21:05
Forty-Bot : however, usually people seem to think it's nicer to only add the constraints on the operations involving the type which really needs the constraint
ski 2017-02-03 07:21:16
@type Data.Set.empty
lambdabot 2017-02-03 07:21:17
S.Set a
ski 2017-02-03 07:21:30
has no `Ord a' constraint, since it's not necessary in this simple case
Forty-Bot 2017-02-03 07:21:30
hm
ski 2017-02-03 07:21:37
@type Data.Set.singleton
ski 2017-02-03 07:21:38
nor there
lambdabot 2017-02-03 07:21:39
a -> S.Set a
Forty-Bot 2017-02-03 07:21:54
I suppose dual dumbers are general enough...
ski 2017-02-03 07:22:11
one *could* argue something similar re your "because it doesn't make sense to take a derivative of something else" comment
Forty-Bot 2017-02-03 07:23:11
do you know how to deal with the Absolute implementation?
mniip 2017-02-03 07:24:02
1486141510 [20:05:10] 18 So mu in the monad is going to look like: forall a c. (exists b. M(a,b) * M(b,c)) -> M(a,c)
mniip 2017-02-03 07:24:10
how does that correspond with the Arrow tyclass?
ski 2017-02-03 07:24:13
`toDual' could possibly be made into `pointed' in `Pointed' (a type class), but only if you manage to hide the constraint (by a GADT, or perhaps by something `Yoneda'/`CoYoneda'-like) .. or maybe there's a variant of `Pointed' which allows you to specify custom constraints ..
ski 2017-02-03 07:24:51
Forty-Bot : perhaps you can use `ZeroTestable' instead ?
Forty-Bot 2017-02-03 07:25:29
Ideally, I'd like to make it instance Absolute.C a => Absolute.C (T a) where
ski 2017-02-03 07:25:34
(i.e., give an error yourself in case you get zero, instead of relying on `/' to error out)
Forty-Bot 2017-02-03 07:26:28
because then for all a -> b there is a function T a -> T b
ski 2017-02-03 07:26:47
in case you want the derivative of `signum' at `zero' to be undefined, rather than `one', i think you need at least `ZeroTestable' or `Field', or something of that ilk
mniip 2017-02-03 07:30:32
if we examine monoids in ([C^op x C, Set], (- . -), hom)
mniip 2017-02-03 07:31:14
then mempty is a morphism from hom to F, in [C^op x C, Set]
mniip 2017-02-03 07:31:25
and mappend is a morphism from F.F to F, in the same
ph88 2017-02-03 07:31:30
how can i pattern match on one item of a record and then return the same record while modifying that one thing ?
ph88 2017-02-03 07:31:52
so that i don't have to pattern match all the fields of the records and then put all the stuff back in
mniip 2017-02-03 07:31:55
so they are functions natural in 2 C objects
Tuplanolla 2017-02-03 07:32:17
Curly braces or lenses, ph88.
mniip 2017-02-03 07:32:33
okay, mempty is arr,
mniip 2017-02-03 07:33:00
but mappend is something like, uh, yes, exactly what you said
ph88 2017-02-03 07:33:06
Tuplanolla, i know it's something with curly braces but i forgot the syntax .. and also on the return i'm not sure
mniip 2017-02-03 07:33:17
but what is it
mniip 2017-02-03 07:33:25
it looks exactly like arrow composition
noan 2017-02-03 07:34:28
ski, I was infact referring to real world days and a feeling of accomplishment over the course of this day
ph88 2017-02-03 07:34:34
Tuplanolla, i have no (which is not compiling): prettyPrint (IExtended terminal@Ter {t_text=(pos_t, t) }) = terminal {t_text(pos_t, '\\' : ei ++ ['\\'])}
ph88 2017-02-03 07:34:53
IExtended has 3 more fields but i want them unchanged
Tuplanolla 2017-02-03 07:35:22
You say `terminal {t_text = ...}` inside the expression, ph88.
ski 2017-02-03 07:36:08
> let frob tree @ Node {rootLabel = r} = tree {subForest = [Node r []]} in frob (Node 0 [Node 1 [],Node 2 [Node 3 []]]) -- ph88 ?
lambdabot 2017-02-03 07:36:10
Node {rootLabel = 0, subForest = [Node {rootLabel = 0, subForest = []}]}
ph88 2017-02-03 07:36:40
Tuplanolla, but i want to change t_text so why i put = ... ?
Tuplanolla 2017-02-03 07:36:57
The idea is to replace the constructor `Ter` with the value `terminal` if you want to reuse existing values, ph88.
ski 2017-02-03 07:37:39
ph88 : is `IExtended' or `Ter' the record constructor which you want to do an update on ?
ph88 2017-02-03 07:37:59
I want to update on Ter
ph88 2017-02-03 07:38:12
good point i forgot to fmap IExtended back on :/
ski 2017-02-03 07:38:17
and `IExtended' is a record constructor ?
ph88 2017-02-03 07:38:47
data BlaBla = IExtended T data T = Ter {4 fields here}
ph88 2017-02-03 07:39:08
i think i just forgot the = after t_text :/
ski 2017-02-03 07:40:00
mhm
ph88 2017-02-03 07:42:03
Tuplanolla, this helped, thank you You say `terminal {t_text = ...}` inside the expression
Tuplanolla 2017-02-03 07:42:33
You'll definitely enjoy discovering lenses later, ph88.
ph88 2017-02-03 07:42:49
:D
akfp 2017-02-03 07:43:04
is there a generalized groupBy?
akfp 2017-02-03 07:43:22
something like (a -> a -> Bool) -> f a -> f (f a)