« first day (9 days earlier)      last day (452 days later) » 

12:31
@false well
I have a few ideas on how to improve it
because the commentary is lacking right now, I might ask you what do you think about it.
12:46
>>= is statement chaining
because the code operating in a context has to keep it somehow
you specify how the operations are going to be chained
>>= can pass state behind the scenes, but it can do much mode
that's the essence of "programmable semicolon"
I even wrote a paragraph about that I think.
> If this was in Maybe Monad, if any of the operations that obtain values failed, resulting in Nothing, the whole function would automatically result in Nothing. The context, being responsible for chaining operations, is able to “look inside” their returned values and change behaviour according to them. There are some laws that dictate what operations are possible, to keep the program’s behavior reasonable, but nevertheless it still offers a lot of possibilities.
and for completeness/utility >> is >>= that discards the return value to chain a computation that doesn't want the return value of the previous function.
-----
at least that's from the practical perspective. Of course `>>=` has a more formal definition, the one that @Cat wrote.
but to understand all that, you need to really read into what do notation is, what Monad laws are, etc. etc. and it doesn't really help in understanding how the hell that applies to anything.
yeah, I did read up on it all, but totally forgot
I mean, right now I am taking your advice, which is that I want to improve the quality of my compiler w.r.t. it's current language features.
I want to offer stuff like more warnings/errors
@DeadMG oh great. I think that it's really that, not lack of new features, that's preventing you/people from writing code in Wide.
I'd definitely want to have exceptions before creating any serious Wide code.
well, no, not really.
nothing verifies the language ideas/implementation better than real-world use, I'd wager.
@DeadMG yeah, those are very important and lack of them can be very discouraging.
and
I guess there are some features where I want to at least know for sure what I want to implement before rolling on.
like for example, concepts.
12:56
aha. Those can be tricky, what the story of Concepts Lite has shown.
Wide is a lot more empowered in such respects than C++ is.
especially not having to deal with the TU system.
I am wondering about the relationship between Concepts and Type Classes.
@DeadMG oh, so the main problems with them were the implementation ones?
as near as I can tell, concepts can serve as type class equivalents.
@BartekBanachewicz As far as I am aware.
well, also the C++ Standard Library.
it's very overcomplicated and conceptifying it was very problematic.
whereas I frankly don't have to.
@DeadMG so, in short, you can define an interface that can be implemented from outside of the class, and then accept implementations of that interface?
yes.
so you might have something like template(type t) concept range { optional(T) operator(); }, then anyone can declare that they are a range(int), say.
12:59
But concepts also can be used to define runtime behaviour, right? Like, guaranteeing something about a class that can't be inferred from its code.
and ISTR that the latest draft of what I wanted for Wide concepts did include having the power to define a monad concept.
@BartekBanachewicz That would be axioms, and they are related but separate features I would say.
@DeadMG baseline monad concept is just bind and return.
still
@DeadMG ah. So yeah, concepts and typeclasses look very similar.
the main thing I can define for sure about Wide is that it needs a lot of work in many areas and I've only got so many hours in the day
I need to attract support, I feel
13:02
@DeadMG you know, I dunno how much have you read about Haskell monads, but the coolest thing they have, imho, is not just the ability to create one. Pretty much every instance of Monad defines its own typeclass. So, for example, State is a Monad, but its module defines MonadState. If you fulfill that, your Monad can be used in place of State.
that's very powerful, because it means that you're writing code against monad interfaces, not against the particular instance.
that just sounds like a concept inheriting from another concept.
mhm! class Monad m => MonadState m where is just that (and it's pretty obvious from the definition)
That's just the thing I found very nice to use, after I understood it :)
but I did come up with a sweet idea for where to find warnings/errors.
Clang comes with files that list all the warnings and errors they can generate.
so I can just cross off the list the ones that no longer apply, like uninitialized variables
then implement the rest.
13:06
you can't have an unitialized variable in Wide?
nope.
So pointers initialize to nullptr, for example?
actually, they're just not default constructible.
I think default construction is a plague that should be eradicated, personally.
what about, say, vector?
use empty range
13:09
I dunno, an empty vector can't break anything.
absolutely yes it can.
it's rather natural to start with an empty collection.
depends on your use case.
@DeadMG well, the code that requires non-emptiness should declare that somehow
you should state whether or not you need emptiness.
13:10
while we're in Haskell, for example, default head can throw.
default-constructing to emptiness is just saying, "I arbitrarily define that emptiness is a special state that everybody should support!".
but the more reasonable one is head :: [a] -> Maybe a
I have used optional<T> as a primary carrier in my ranges.
@DeadMG Do you know what a Monoid is?
no.
13:11
it's another concept, much easier than a Monad
it defines two operations.
`mzero` - giving you an empty instance
`mappend` - appending an element
in this case, it's rather natural, that mzero for a list is an empty list.
Monoid is used a lot in Haskell, and so I think that yes, emptiness is a special state.
that's only true if you are writing against Monoid.
but it's very useful! I'll give you an example
but you have absolutely no guarantee that guy taking a vector<T> can accept an empty one.
the interface does not require that at all.
he can only take an empty one if he specifies that he can.
@DeadMG well, it specifies that it can take any valid vector. Empty vector is a valid vector.
well, that's only the static precondition.
many functions have preconditions you can only assert dynamically.
13:15
I thought you were just against making empty vector special.
I am.
@DeadMG of course. But if we're looking at static properties, an empty vector is a perfectly valid argument to said hypothetical function.
yes, but so what?
the call is just as invalid if you pass an argument that breaks a dynamic invariant as a static one.
but you can't ultimately protect from dynamic invariants statically.
no, of course not
but what you can do is not assume that one particular dynamic state obviously meets those invariants, even when you have absolutely no idea what those invariants are.
13:17
I just think that default instances of said Monoid concepts are useful. Not providing it makes a lot of code more verbose.
eh... with tuple-init it would be as hard as var := std.vector(int)(); vs var := std.vector(int)({});.
not exactly a big difference.
I'm actually not wholly sure if I can make my tuples behave that way but I'm pretty sure I can.
can you initialize a string with {}? I guess you can.
er
dunno but I doubt it.
you'd probably have to use "".
ah, see, so that's where it gets harder. If you implemented Monads, MonadWrite requires its inner type to be a Monoid.
you can't easily model that, because you'd need wrappers for Strings and Vectors that default-zero-initialize
no problem.
after all, mzero is a function, isn't it?
13:22
of course.
then no problem.
well, maybe you're right.
You can't use Int, directly as a monoid for example; you have to pick either Sum Int or Product Int., with respective mzeros being 0 and 1.
good.
see, int is a fine example.
so it could be ok to use Empty String or Empty Vector
you might say that 0 is a reasonable default, but only if you're adding... if you're multiplying you might well really want 1.
13:24
mhm.
I just don't think such cases exist for string or vector.
matrix has different identities for multiplication and addition too.
Well, I can imagine that for Path, for example, empty one would be bad alright.
@BartekBanachewicz They exist far more widely, because there are way more dynamic states for a vector.
and way more operations you can perform on them
Hm, could you provide a general example of such Vector instance that would initialize, say, Vector<int> to [0] (or anything other than {}/[])?
I just don't see the practicality, is all.
well, here's a really simple example
if you have a Wide function, then it has this method BuildCall() which constructs a run-time call to that function, and it takes a std::vector of arguments.
but it's pretty clear in advance that the arguments have to match the function's parameters.
a random empty vector -> bad.
13:28
but that's not a sequence that can change in lenght anymore.
hm, well, if you count overloads... but even then, it can have a lenght that is one of the set
right... but when you're talking about some Function
then you can define some Function that has any number of arguments.
and what would the default state be for that, then?
so it's pretty clear that the general Function interface has to accept a variable-length structure.
@BartekBanachewicz There really isn't one.
you can't pick arguments out of your ass.
you have to have values of the right type and number.
13:30
so what you're saying is... unless you specify a context with a reasonable 0 for a particular type, there's no 0 for it.
that kinda makes sense.
well, it would be a particular argument to a particular function...
other functions or other arguments might have a reasonable default.
yeah, but it would require stating it, right.
but you could, and I do, argue that if there is a reasonable default, then you should provide a default argument on the interface.
or in C++ then use overloads because default arguments are shit there
@DeadMG um.. isn't reasonable default all about not having to do that?
like I said, you can only define reasonable default in terms of what you're going to do with that default value.
and only the interface author knows what constraints are on his operation that he is defining.
13:32
@DeadMG I mean, the first thing I'd do is create the Empty concept and instantiate it for Vector and String and whatnot supplying those, so I don't have to think about them later.
right, but in this case, you not thinking about it means you fuck up.
because your Empty is not a valid default argument to a Wide function call.
but it can be a valid instance of a Monoid.
And hence, it can be a valid type for MonadWriter
that's only useful if the guy writing the interface says that all possible Monoid values are acceptable.
which is the case quite often, actually.
far from guaranteed.
making random assumptions about what is and isn't acceptable is where bugs come from.
13:34
Anyway, it remains safe, there's no problem here.
You have to be explicit about that Empty thing.
both on declaration and getting the value later!
so, as you said, you can't pass that to a wide function directly
you have to take Empty String, and if you want to pass it to a function f(String), you have to extract it manually
this time fulfilling the contract on f, for example if (es.value != "") f(es.value); else ...
eww, better a Maybe String
yeah.
nah, Maybe and Empty are different.
but here's the best part
you can use both equally, if you wiggle with MonadError a bit :)
then bind can automatically discard empty strings or no strings at all, breaking the computation
now that I think of it, I quite like your approach.
hmm.
if I have a function, and it's generic (like a template), do I issue warnings for each instantiation?
Maybe skip the same warnings?
like, I could have template<typename T> int f() { if (sizeof(T) > 5) return 1; }, pretty clear that some instantiations should be warned on but not others.
13:42
but would the warning even appear for the cases where sizeof(T) > 5?
not after I implement constant folding stuff.
right now I have not, so it would.
@DeadMG well.
I guess also, it takes longer to recompute the warning for each instantiation.
maybe I should only accept stuff like if(true) and while(true) as unconditional.
13:55
I guess what I'll do is discriminate between "Warn on instances x, y, z, .." and "Warn for all cases"
 
4 hours later…
17:55
hi @false
I see you :D

« first day (9 days earlier)      last day (452 days later) »