03:36:01 <carter> neat
05:29:34 <stepcut> I did real work too :)
05:59:16 <carter> sure :)
14:54:26 <stepkut> donri: I hacked up a little category+applicative based reform, http://lpaste.net/6231306018106638336
15:01:01 <donri> interesting, any apparent downsides?
15:01:17 <donri> i wonder if we could use DataKinds to finally make the proofs truly enforced ;)
15:02:19 <stepkut> I don't see any downsides
15:02:21 <donri> i suspect Form is not a legal Category though
15:02:25 <stepkut> oh ?
15:02:27 <donri> for the same reason my Path originally wasn't
15:02:35 <stepkut> I have not gotten that far yet :)
15:02:40 <donri> Comp isn't associative, i think?
15:03:03 <stepkut> because of the side effects?
15:03:09 <donri> also it looks like it is in fact a path category, aka a free category
15:03:17 <donri> i've been wondering if it would be useful to split that out of my path package ;)
15:03:54 <stepkut> I have an idea on how I could generalize things even more so that I could do client side validation and form generation
15:04:22 <stepkut> more specifically -- have a single form that can be generated and validated on the server and/or the client
15:04:34 <stepkut> but that comes later
15:04:50 <donri> stepkut: i mean a . b . c will either be like ((a,b),c) or like (a,(b,c)) depending on precedence, but you actually want [a,b,c]
15:09:04 <donri> that is Comp doesn't "flatten" the composed forms, and it "remembers" how it was "associated"
15:09:52 <donri> it might not matter for the final result but it won't be "correct by construction" :)
15:10:09 <stepkut> hmm
15:12:52 <stepkut> I wonder if I can implement 'first' using just things from Functor, Category, and Applicative
15:13:04 <stepkut> and 'arr'
15:17:47 <lpaste> donri annotated category form with associative category at http://lpaste.net/6231306018106638336#a95903
15:22:26 <lpaste> donri annotated category form with Category instance at http://lpaste.net/6231306018106638336#a95904
15:22:42 <donri> not tested but loosely translated from my Path
15:22:54 <stepkut> spiffy
15:23:51 <stepkut> in terms of making the type-checker happy, you can define Arrow in terms of Category+Applicative,
15:23:53 <stepkut> instance Arrow (Form m input error view) where
15:23:54 <stepkut>     arr f     = fmap f id
15:23:57 <stepkut>     first f = pure (,) <*> f . arr fst <*> arr snd
15:24:00 <stepkut>  
15:24:03 <stepkut> but, proving the laws is not automatic
15:24:44 <stepkut> more specifically, your Category and Applicative instances need to follow some extra laws if you want to ensure that the Arrow follows all the Arrow laws
15:25:29 <stepkut> I like the idea of having, Functor, Category, Applicative, and Arrow instances for my Form type though
15:26:10 <stepkut> with only applicative, you only have one way to compose forms
15:26:16 <stepkut> but with category, you get a second way
15:26:43 <stepkut> with applicative-only you can't have the result of one form depend on the result of another
15:26:47 <stepkut> but you can with category
15:27:01 <stepkut> but unlike monad, that does not screw up form rendering
15:27:29 <stepkut> because it ensures that only the value parts can depend on other form elements, not the view parts
15:27:43 <donri> yeah instead of Form -> b you get a -> b where a may be Form, but also might not :)
15:35:20 <stepkut> I am not clear that the data types enforce the laws by themselves anyway?
15:35:31 <stepkut> like.. one category law is:
15:35:35 <stepkut> f = id . f
15:35:50 <stepkut> and, the current instance does not enforce that either
15:36:59 <stepkut> instead you would have, f and (Comp Id f)
15:37:09 <stepkut> though I could pattern match that away in the category instance
15:38:06 <donri> stepkut: with my version, neither Form nor Cat are actually categorical themselves, so it's enforced by forcing you to use the Category instance
15:38:34 <donri> stepkut: Cat is just a linked list, which satisfy identity and associativity
15:39:20 <stepkut> I am wonder though.. do I need to optimize away the 'Comp Id' in my Category instance?
15:40:09 <donri> stepkut: that already happens
15:40:20 <stepkut> instance Category (Form m input error view) where Id . f  = f ; f  . Id = f
15:40:38 <stepkut> oh, I see, in yours you do that ;)
15:41:01 <donri> well i do the latter, but you should get the former for free from the Comp one
15:41:28 <donri> i think i wrote it wrong though, in my Path it's written as flip (.) so i had to unflip it by hand
15:41:36 <donri> https://github.com/dag/path/blob/master/src/System/Path/Internal.hs#L147
15:41:46 <donri> and line 172
15:42:50 <donri> (.) = flip (</>)
15:43:09 <donri> i just don't have a Category yet because it needs PolyKinds which needs ghc 7.8 ;)
15:44:39 <donri> @src (++)
15:44:39 <lambdabot> []     ++ ys = ys
15:44:40 <lambdabot> (x:xs) ++ ys = x : (xs ++ ys)
15:44:40 <lambdabot> -- OR
15:44:40 <lambdabot> xs ++ ys = foldr (:) ys xs
15:44:42 <stepkut> so splitting out the Cat data type ensures that the user can't manually construct a value with the wrong associative behavior -- but if they only used the Category instance -- then that is not needed, right ?
15:45:22 <donri> stepkut: well you could hide Id and Comp, and ensure associativity in Category, but that's also going to be more involved because you'll have to flatten it
15:45:36 <stepkut> yeah
15:46:52 <donri> for Path i wanted to export the constructors and have it correct by construction
15:47:11 <donri> it also simplifies things for me because getting the root edge is just "head"
15:48:26 <stepkut> the odd part now though is that I have two things.. Form and Cat
15:48:45 <donri> and generally it's easier to reason about something that is list-like and correct by construction :)
15:49:36 <donri> yeah. in math, the free category is actually called the path category because it represents a path in a graph. so Form = edges, Cat = Path, and in your case the vertices are the objects of Hask
15:50:11 <donri> it's similar to how you have a separate functor and Free wrapper with free monads
15:50:25 <donri> if you put everything in one gadt, you don't get associativity
15:51:20 <donri> (in path i just used the graph theory terminology. haven't decided if i'll keep it like that or not.)
15:51:51 <stepkut> how do I lift a Form to be a Cat :-/
15:52:00 <stepkut> I would have to do, Comp frm Id, I think
15:52:05 <donri> yep
15:52:09 <donri> same as singleton x = [x] :)
15:52:12 <stepkut> which violates, f . id = f ?
15:52:17 <donri> ie x : []
15:53:27 <donri> no, because . is ++ not :
15:53:35 <donri> Comp is :
15:53:45 <donri> i have quickcheck tests that verify my Path is lawful
15:53:50 <stepkut> not sure how I feel about this
15:53:53 <donri> i didn't like it first either, when i had to do this
15:54:11 <donri> but it all worked out for the better :)
15:54:12 <stepkut> anyway, you can generalized Cat even more
15:54:12 <stepkut> http://lpaste.net/7825550152705245184
15:54:29 <donri> sure, that's what i meant by "splitting this out of my path"
15:56:53 <stepkut> i think I would feel better if there was a third constructor,      AsCat :: c a b -> Cat c a b
15:57:12 <donri> i actually wrote mine like that at first, but then you can't derive Eq or Show because of some ambiguity
15:57:22 <stepkut> so that I wouldn't need to have that extra, Comp and Id to construct a value
15:58:22 <donri> data [a] = [] | [a] | a : [a]  -- not sure i think that's a better definition for list ;)
15:59:11 <stepkut> :)
15:59:36 <donri> and i tried something like it too, but without Id, ie. the free semigroup
15:59:50 <donri> but then it's not a Category
15:59:57 <stepkut> well.. if I am going to have a type for Cat, I should have one for App and Func as well I guess
16:00:41 <donri> duno, haven't looked at that. Comp just stuck out for me because i had just recently dealt with the very same thing :)
16:24:47 <donri> there's a free applicative in the free package
16:25:52 <donri> looks exactly like your Ap and Pure though so maybe not needed?
16:26:03 <donri> i imagine you can drop FMap give liftA though
16:26:46 <donri> but i guess you feel about that like about Comp Id ;)
16:30:27 <donri> actually without Cat you don't get identity either, since you id . id /= id, etc
16:32:16 <donri> stepkut: there is a way to keep everything in one gadt but it's silly and ugly... add another phantom type ;)
16:34:08 <stepkut> there is something useless..
16:34:10 <stepkut> data Functor' f a where FMap :: (a -> b) -> Functor' f a -> Functor' f b
16:34:27 <donri> :D
16:34:29 <stepkut> s/there/here/
16:36:38 <donri> i wonder, is this just a silly formulation of the identity functor
16:38:11 <stepkut> I think the only instance you can create is, testF :: Functor' f a ; testF = FMap id testF
16:39:17 <donri> oh right, hah
16:40:13 <donri> the f isn't actually used
16:41:54 <stepkut> its more that you can't construct a Functor' unless you already have one..
16:42:43 <donri> actually
16:42:56 <donri> now that you have testF, can't you FMap any function on that?
16:43:17 <stepkut> hmm, yes?
16:43:45 <stepkut> still.. you'll never get anything done since it is an infinite list
16:43:57 <donri> :)
16:44:41 <donri> is that what a pointed functor is (is that a thing?)? applicative sans ap? hm
17:30:18 <stepkut> so I can use Cat and the free Applicative thing separately.. but combining them seems to be a bit of a pain
17:41:05 <donri> hm is (Cat a) a functor?
17:41:30 <stepkut> no ?
17:43:39 <donri> i guess it's a functor for Id and the inner-most Cons... or something like that
17:43:47 <donri> uh Comp
17:45:55 <donri> hm but isn't that what your current FMap does anyway
17:46:05 <stepkut> I'm not using that FMap anyway
17:47:21 <stepkut> I can do this.. http://lpaste.net/8349116450023145472
17:47:23 <stepkut> but now what?
17:48:15 <stepkut> I now have 'App (Form view a) b' and 'Cat (Form view) a b'
17:48:22 <stepkut> but I need to unify them somehow
17:49:35 <donri> i was thinking you would have Ap (Cat (Form m input error view) a) b
17:50:13 <stepkut> hmm. the Ap outside the Cat
17:50:18 <stepkut> I didn't try that direction
17:50:47 <donri> not sure how to make that a Category though
17:51:36 <donri> Cat (Ap (Form m input error view) a) b
17:51:39 <donri> and make Form a Functor?
17:52:11 <donri> eeeh no this doesn't work either
17:52:18 <stepkut> right
17:52:37 <stepkut> you can try having two constructors.. but I don't think that works either?
17:54:06 <donri> might be interesting to look at netwire http://hub.darcs.net/ertes/netwire/browse/Control/Wire/Core.hs
17:54:16 <donri> mm_freak: care to share your netwire form thingy?
17:54:58 <stepkut> so, netwire defines a type that is an Arrow, which means it is also a Functor, Applicative, and Category
18:03:33 <donri> don't think Wire is a free object though, maybe that's the trouble we're in, hm
18:05:12 <donri> also any time i read stepWire i think stepCut ^_^
18:05:17 <stepkut> :)
18:05:33 <donri> wire cutter? \o/
18:06:45 <donri> Cat (Ap (Form m input error view a) b) a b  -- couldn't be this simple, could it...
18:07:12 <donri> gah no
18:07:26 <donri> fucken kinds, man
18:17:00 <donri> so can we perhaps make a single gadt for a free Cappligatory? we already have Pure with Comp Id, can we add Ap?
18:22:08 <stepkut> Category+Application -> Arrow
18:22:34 <stepkut> but, yes -- that is basically what my original type did, plus on other thing
18:22:51 <stepkut> but you didn't like the balance of the Comp operator
18:24:22 <donri> :) i know, just pondering if they can be unified without sacrificing laws
18:31:00 <donri> or perhaps Cat itself can be Applicative
18:32:16 <stepkut> to make Cat application you need to be able to make a Functor instance..
18:36:39 <stepkut> so the function instance should obey the law:
18:36:41 <stepkut> fmap id  ==  id
18:37:12 <stepkut> but.. clearly that can't happen at the data-type level.. because we have no way to know if the function being applied is id
18:37:42 <stepkut> that is something that the function which evaluates the structure must obey
18:45:17 <donri> pretending Cat is linked backwards instead, fmap g (Comp f fs) = Comp (g f) fs, ie. fmap on the "head", the only form with target type "b"
18:45:29 <stepkut> something a bit like, http://lpaste.net/7108364380336553984
18:45:30 <donri> then Form needs to be a functor
18:45:42 <donri> and we have reduced Form to View and Label
18:45:55 <donri> can we fmap on those?
18:46:02 <stepkut> hmm
18:47:15 <stepkut> oh, my view function is wack
18:47:17 <stepkut> one moment
18:47:38 <donri> hm or are a and b just phantoms now, hm
18:47:46 <stepkut> no
18:47:49 <stepkut> that is just me being dumb
18:50:13 <stepkut> it should really be, data Form view val a b where View :: (FormId -> view) -> Form view val a val
18:50:47 <stepkut> for which you can not directly implement a Functor instance
18:51:53 <donri> still phantoms...
18:52:09 <donri> i don't think we want the Const functor here
18:53:44 <donri> maybe we do still need Pure ...
18:54:51 <donri> yeah because it's not the same as Comp Id
19:35:39 <stepkut> hmm, I think when I split the View out of the rest of the Arr, the GADT doesn't have enough power to enforce the types
19:39:18 <stepkut> I think I would need to fold the View constructor into the Arr type basically
19:39:37 <stepkut> but then I would need to modify Comp to take two Arr and then it would be a tree instead of a list
19:39:52 <stepkut> or I need to remove Comp and make View act like View+Comp
19:43:01 <stepkut> but then how would I make it a Category instance :-/
19:43:23 <stepkut> oh
19:57:17 <donri> gah i almost have something but a bunch of undefined i can't figure out
19:58:06 <stepkut> :)
19:58:22 <lpaste> donri pasted “Form” at http://lpaste.net/95916
20:03:08 <stepkut> right.. you can't fmap on a view
20:03:10 <stepkut> a View
20:03:24 <donri> in deed
20:04:19 <donri> i think the undefined on the last line should be fixable, but my brain is melting
20:05:14 <donri> although there'll still be undefineds for Id
20:12:46 <stepkut> hmm. even if I roll View+Comp into one piece -- there is not enough type information available
20:12:54 <stepkut> I am now back to my original formulation :p
20:33:40 <stepkut> oh what -- I may have gotten unstuck
21:17:02 <stepkut> oh hmm. didn't complete my Applicative instance
23:41:49 <stepkut> donri: this is the closest I have so far
23:41:50 <stepkut> http://lpaste.net/5479024749407371264
23:42:43 <stepkut> if I make Comp have the type, Comp  :: c a b -> Arr c b c' -> Arr c a c', then I can not figure out how to create the Category instance for Arr