Player is loading...

Embed

Copy embed code

Transcriptions

Note: this content has been automatically generated.
00:00:28
yep now now it works i guess yeah okay cool
00:00:32
okay so uh mistakes i made when designing in presents and
00:00:38
also some things we got right and to understand that i think it's a good to actually go back
00:00:43
in time and uh that have a look at the history of it this is how they came about
00:00:48
what where the the ideas the guiding ideas why we arrived at the design that we have today
00:00:55
so actually the first uh version of scott i
00:00:57
didn't have interested parameters it only had conversions implicit conversion
00:01:02
so in two thousand for for scholarships with improved versions and why didn't have implicit conversions well
00:01:09
at the time there was a very pressing problem also people believe that was the lake extension problem
00:01:15
the the problem was is that we have essentially a number of classes and interfaces or try it's
00:01:21
and essentially there was this tension between structure typing in normal typing
00:01:26
so structure typing said well the advantages we
00:01:29
can have a class implemented tried after the fact
00:01:32
just that the try 'cause right methods of the class it gives you stopped writing relationship
00:01:37
and with normal typing you don't have that you have to declare that the classics
00:01:41
then subtract and you can do that only menu right the class not after the fact
00:01:46
so the late extension problem was well how can we make classes in her tried after the
00:01:50
fact that was actually a big big uh uh uh thinking it was also for instance um
00:01:56
still unsolved problem for job about the java design is very much thinking about the problem
00:02:01
and so was i and uh the i couldn't come up with a good solution really so
00:02:06
i went back and forth how how could we do this and in the end that's at all
00:02:10
but essentially on a very simple half solution little solution it is i well yeah we
00:02:15
have this tried and the class and they don't extend the class doesn't extend to drape
00:02:20
but what we can do is we can write a wrapper from the class to the
00:02:23
try it just creates a new version of the pride and we can make that wrapper automatic
00:02:28
so we're born implicit conversions and they were the the
00:02:32
the reason for implicit conversions was this late extension problem
00:02:35
of course implicit conversions can do way more than that so by now
00:02:39
this use case we would probably or express as an implicit class implicit conversions
00:02:44
have other other use cases that another present classes uh the so
00:02:49
uh it's very very powerful it's also very easy to uh abuse
00:02:53
and at the time that wasn't really being the problem because we weren't really thinking much about essentially what to
00:02:59
a millions of for hundreds of thousands of programmers do
00:03:03
with this we didn't we had maybe ten programmers so twenty
00:03:06
and it wasn't really a big deal to say you have very powerful feature that you can abuse
00:03:12
so the second step then burns got to the chip about two thousand six uh into the parameters uh
00:03:19
once we have uh the basics of inputs a good solution so we had to find
00:03:24
say well where are these things found how would how how are they resolved and things like that
00:03:29
it was very tempting to say well we can actually do imprison parameters as well the deltas very it's very small
00:03:35
and uh the expressive power off because of
00:03:38
parameters includes type classes so this was very tempting
00:03:42
so i actually found it properly gave in two thousand six
00:03:46
hundred just jump into some of the slides of the stock um
00:03:53
so so that was the top moments type class that was given that the
00:03:58
w. g. two point eight working group meeting in boston july two thousand six
00:04:02
w. g. point a to point eight is the working group for function program
00:04:08
uh be this guide to the to discuss a lot of uh uh
00:04:12
these days with this 'cause a lot of hard yeah and uh and
00:04:15
cock and and and uh uh and and the essentially the source of
00:04:20
dependent typing cynthia improve was at the time it was sort of a
00:04:24
has got camp and then an l. camp and the small that's a camp and i was sort of the ottoman out and i okay
00:04:30
so uh these so could talk said well type classes are nice
00:04:34
and the cottage industry of pascal programmers it's been about about them
00:04:38
should we add them to object oriented languages specifically discount so interesting at the times
00:04:43
got was from the object oriented language it didn't count as a functional language some
00:04:48
um and the problem was that it's conceptually expensive because we already
00:04:52
spent the people keywords type and glanced so what should commercial type telescope
00:04:57
and furthermore type classes are essentially implicitly past dictionaries and dictionaries are is essentially
00:05:03
records that means objects for us and we don't want to duplicate that so
00:05:07
the idea was to concentrate on the delta between oh oh
00:05:10
classes and type classes and that's implicit so that was the idea
00:05:14
so then i introduce a standard example within the group
00:05:17
and manipulated by without type classes what would you do
00:05:21
uh we would uh essentially right the two things like this and then if you want to
00:05:26
make it some over a less than we have to pass them on every instance explicitly so
00:05:31
that's what we would do we would pass it and and uh that's that's the standard thing of
00:05:36
course and then the the idea of course was well can be avoided boilerplate of plastic these things
00:05:42
and that's when i introduce unimpressive parameters so easy at first time in on the side i guess
00:05:48
and uh the ideas you should be able to
00:05:50
combine on into the parameters and the implicit parameter
00:05:54
list has to come last ah i'll get to that why why that restriction was there from the start
00:06:01
and then finally impose it can also be used as a modifier for definitions and then uh that i mean shut
00:06:07
the these arguments here can be inferred because just because i've
00:06:11
seen of course so uh he s. the fine print now
00:06:16
say well to infer an implicit argument how do we do that
00:06:19
so that you say an argument is people to be hard if it's
00:06:23
itself labelled implicit of course it's type is compatible with the unexpected type
00:06:29
yes and one of the following the whole so that's that's important part
00:06:33
the first the things that makes it accessible at the point of call by a simple identifier
00:06:38
i it that it means it's defined in the same scoping heard that were important
00:06:43
second says exist define the static value also value of accompanying object
00:06:47
in some superclass of three so that's already the two different a resolution mechanisms the first one is
00:06:54
exactly the the car current context and the second is the implicit scope of
00:06:59
the type that was number two and uh that's also sort of already this this
00:07:04
sentence it's very concise it's very crisp uh as a
00:07:08
specification it's beautiful but we'll see like that that this this
00:07:11
one sentence cost quite a lot of problems of usability of inputs its its base it was basically a thing where
00:07:18
you'll be of this fact was traded for economics of use and that that was sort
00:07:22
of the big given off of a of a number of of shortcomings of implicit see
00:07:27
okay you several arguments x. eligible choose the most specific
00:07:30
one and if no specific eligible argument exists type or
00:07:36
okay so then the other thing was uh about locality so
00:07:41
that was the reason why we do not want global coherence uh
00:07:45
so uh be can have we should be able to
00:07:47
have several instances of the same operation at the same types
00:07:52
uh the so in that sense i was in either the ruling out global coherence because
00:07:57
in a job setting the but global literally has
00:08:00
no sense if you follow trends that it's class dependencies
00:08:04
you pull in the internet so you could it's of heated talking about global you're not
00:08:08
permitted to that so that that that's why global coherence was essentially didn't right from the start
00:08:14
yeah but now comes another thing and i think that's actually one of the important things we got right
00:08:19
so here we have essentially coherence coherence it's a loaded term uh if you look at the literature that
00:08:25
coherence basically means it's not ambiguous the compiler picks one
00:08:29
instance and there's other than the maturity wannabes uh so
00:08:33
so that's it in that meeting that it's not ambiguous so want to
00:08:36
keep it is if you have a partially applied methods like have a method
00:08:40
you don't class all its parameters being you pass the
00:08:43
implicit parameters at the time you convert limited to function
00:08:47
so that's a question you can answer it either way you can say yes or you can say
00:08:52
no i will which actually i i passed this thing as a method that takes in this apartment
00:08:57
there was a print assessor of uh it was a problem or should i put this as a one
00:09:02
another language use the work has still use the word of course impressive parameters comes from has got it was
00:09:08
invented six years earlier eh in two thousand but actually
00:09:11
our but the parameters only share the name and they have
00:09:15
basically gave a little to do with pastels impressive parameters and that's one of the things where we
00:09:19
actually different caskets impressive parameters effective what type essentially
00:09:23
the input of parameters also those listed for the expansion
00:09:27
and for us uh the answer is no we don't do that
00:09:30
to be passed into the parameters as the point of it expansion
00:09:33
and i think in retrospect that wasn't being he really excellent idea uh it it
00:09:38
it avoided a lot of the shortcomings that you have with impressive parameters in pascal
00:09:43
okay then you have conditional implicit i don't think i have to go into that typical list mono it
00:09:48
um and then the just go back and say so in summary what we had at the time to say uh in
00:09:55
this should be well known for everybody will now is to say uh type class in has got it in the class
00:10:00
an instance decorations inquisitive ignition a context in the class that i work and
00:10:06
a complex that type is an implicit parameter dictionaries an object
00:10:11
uh and then him yeah before method is uh oh yeah the fourth method in a in a class
00:10:16
so that's a concrete member of could type and a method secure genotype classes on napster and so we basically
00:10:23
had a d. v. d. fundamental workings of quite classes but the
00:10:27
simple fact i called so let me go back to my other presentation
00:10:40
uh_huh skip forward
00:10:47
okay so i believe things we got pride or it's lead it is to say things which
00:10:53
i mean of course you can make a different choice for each of them but
00:10:55
things i stand by to say that was the right decision and we keep that
00:10:59
is that type classes i types not some sort of setups kinds of some sort or other sort of
00:11:05
sets of pipes dictionaries have values uh instances can be
00:11:09
defined anywhere local instances of possible no global coherence requirement
00:11:16
and uh the relationship it into expansions all glass it's up past and expanding
00:11:21
context so that's along the so called points and i think these are all
00:11:24
essentially the core of scanning plus it's which actually have a lot of advantages of course it's always a tradeoff
00:11:31
sometimes advantage disadvantage but i think these have enough advantages that we say well that that those were good good decision
00:11:38
but there are also a number of mistakes that we made in these tapes in ergonomics is takes in usability
00:11:44
so i get to them now uh the first mistake i believe was
00:11:49
uh that be defined implicit as finding this unique name to say implicit means
00:11:55
if it's a simple identifier that you can infer that's fine that that's
00:11:58
what the specs and not nothing more so you just you synthesise the name
00:12:03
are you so that's the one you get the compiler has to guess but not yes but the right what the name is
00:12:09
and then you put the name in the program and the program should type check with that night
00:12:14
so uh what that means is names ah the name matters a
00:12:17
lot because uh and in particular that because shadowing it's a problem
00:12:22
so if you have this impressive here uh and then we want to
00:12:26
use this uh the easy calc class or that type or of the implicit
00:12:31
somewhere locally where we have another name and scold me
00:12:34
a wind here implicit a resolution perfect because it as well
00:12:37
i can't infer the name any because in a in a in this thing if i replace the you think i
00:12:43
it means this thing here and hope that not that thing over here and it is a different type of it's not inputs so i can't do
00:12:49
so that is a problem in the sense that uh from then on everybody had
00:12:55
to pick very uncommon names for inputs it's in order to avoid the shadowing problems
00:13:00
means that why hard to pronounce hard to remember and that was sort
00:13:03
of essentially it meant it's o. four how can you say it's it's you
00:13:09
forced obfuscation sort of programs you had to pick on common in for implicit so the
00:13:14
name was the was essentially worst and worst worthless right so the name obscured your program
00:13:21
okay then second mistake with the same resolution rule was that nice
00:13:25
thing does not matter so 'cause if you get as it consenting we
00:13:29
put a name in the program it doesn't matter where the 'cause it is define anyway find anywhere as as long as innings was good
00:13:36
and yet you can very easily get ambiguity clicks so here we have uh
00:13:43
maybe one probable intrinsic value a which sort of get credit through your program
00:13:48
and eventually would probably a potentially end up is implicit parameter for this as
00:13:53
but here we actually chose another name for the parameter e. v. so because the
00:13:57
two names are different you would get an ambiguity or compiler would would would essentially
00:14:03
a flat this thing is an ambiguity because because we i and it could be
00:14:08
uh so that's sort of annoying it means you have to have a lot of men disciplined in our
00:14:13
uh thirty compiler very probably use a lot of the same
00:14:16
process at the thread through everywhere that's essentially the complex object
00:14:20
we take great pains to say everywhere it's e. t. x. column context if you wanted to
00:14:25
we name that too i think the x. immediately brawl with things would would would grow up you have to use that night
00:14:31
and that's a shame because it means that uh would be a a guns n. she uh you don't
00:14:38
have at our disposal um a solution to these so called local coherence problem
00:14:44
so what's a local coherence problem the coherence problem
00:14:47
is that you're half a um ambiguous implicit like
00:14:52
here that's a f. instance which is both a
00:14:54
monad and the traverse one up and reversible extent funk
00:14:59
so that means that if you want to then call let's say um now uh on
00:15:04
uh this half a on a on a value off this f. type half of a
00:15:08
then it's ambiguous you might want to the monad map or you might want to traverse map
00:15:13
and uh never mind that monotone troubles probably have inherited them at from funk though so it's the same
00:15:20
so there was a paper written about this by either but try
00:15:23
and uh that's got a symposium to to seventeen by essentially he uh
00:15:28
points out this and then discusses pork potential solutions and and the uh the fact
00:15:34
that well there's there's nothing really good you can do with current because it's sort of
00:15:38
recommendation was a big problem maybe two we should consider global coherence
00:15:43
um but actually there is a very very simple local solution to this
00:15:47
if nesting is significant so he would be the solution the same thing here
00:15:52
the bit dark here so that that a line that that matters that we could say well okay so we have a bifurcation
00:15:59
a monad in traverse in this local context you have to do some believe it and the way because somebody that is to say
00:16:05
just to another implicit value that as a of type fun for in this case the common type loud
00:16:10
every side arbitrarily pick one or the other big mono topic traverse usually that mean the same a
00:16:16
map but the compiler doesn't understand that does a compiler is too stupid to understand that we just haven't
00:16:22
and that's okay i mean in this case the simple case we could of course
00:16:26
to prepare i have asked fun fun play instant as the implicit parameter to map
00:16:30
but typically things are more complicated that this thing gets passed to
00:16:34
many more functions and you don't want to essentially and the argument
00:16:37
might might be a lot more a complex all this what you
00:16:41
pass might be an implicit that has this thing at some small part
00:16:44
so uh the explicit passing argument the paper i could convincingly that that's something woodrow
00:16:50
but this little simple localised isn't the direction i think it's quite acceptable for
00:16:55
this use case over everything but if you have to do it and that's
00:16:58
what we do but of course with the current implicit rules that doesn't doesn't
00:17:02
work because now you don't have to instances of fun to you have three
00:17:07
you would be only increased right so that's that's another solution that would be a solution only with nesting
00:17:13
okay so that was uh the two problems that web
00:17:17
see it came with the simple rule to say uh uh
00:17:20
if you agreed open impressive it's the name that counts and i think that was in retrospect that was a mistake um
00:17:26
the problem is at the time of course with have no use cases so what you do is you crap for the spec rule that
00:17:32
sort of it's crisp list and clearest and this one but was that but the then
00:17:36
um something that is best for the spec is not only test for usability sh
00:17:41
so another mistake we made i think is that coming from implicit
00:17:46
conversions we just said well let's just for use implicit for everything
00:17:50
and that meant that concepts that they're quite different way too close syntactically together
00:17:56
here are the two versions of a first is that's impressive
00:18:00
f. a. and the second first impression a implicit x. t.
00:18:05
and of course the two things are quite different in in
00:18:08
in the use cases the first one is an implicit conversion
00:18:12
from peak to you and the second one is uh uh could visually
00:18:16
impressive that if you have a p. it will give you a you
00:18:21
so the second one is basically a a parameter of type
00:18:24
class and the first one is the conversion and of course
00:18:27
the to have nothing to do with each other the problem
00:18:29
is that fine now we are sort of a uh this um
00:18:36
not pushing conversions anymore thing but you should be very careful with conversion the bad thing
00:18:40
uh where's we are very happy to use type classes including tight conditional type classes
00:18:46
uh but the problem is for new comedies to think that actually quite difficult
00:18:50
to distinguish one from the other and it's very easy to make a mistake
00:18:54
okay uh the related to that to the sort of two
00:18:59
similar to to to familiar with with with with current syntax is
00:19:03
the the question of parameters so again because it was sort
00:19:07
of the shortest distance from what what existed we said that
00:19:12
a uh implicitly a parameter can be passed explicitly
00:19:16
and it's just a normal application so we don't invent any new syntax or anything for that there's just a normal application
00:19:23
uh but that had as a consequence that implicit yes is
00:19:27
actually a leaky obstruction so uh if you have here this function
00:19:31
f. in it takes an implicit parameter and then it returns some
00:19:35
sort of function from you to be use just a function value
00:19:39
then if you would write half of you where you with should slap into this argument but of course that would be a type
00:19:45
error because the you would match with implicit so it would say
00:19:48
well you got you by the u. i. p. the implicit parameter
00:19:53
uh with what you have to do in this case you have to write f. got apply you
00:19:58
so that means it's a leaky abstraction impressions should be invisible but here they're very visible
00:20:03
and furthermore the way you work around that is again leaky but you can't
00:20:08
use next function applications anymore you have to use the underlying construct the apply so
00:20:13
in a sense it's but it's it's doubly bad it was it
00:20:16
really doesn't shine through and you can't use nice function obstructions anymore
00:20:21
okay that was the uh number four mistake i that's one
00:20:25
more and then we stopped and uh that uh implicit import
00:20:30
we're also too close to normal once it was the same argument well we already have imports
00:20:34
implicit should be just essentially one addition i mentioned uh that's just pretend like normal imports um
00:20:41
uh and the problem now had to do also with the names of implicit it's uh so we
00:20:46
we know that it does it have very hard to remember into
00:20:48
tightening so uh that makes it very unappealing to actually use nine imports
00:20:54
for when when we need important interested because nobody remembers those names
00:20:58
and they're very hard anyway very long and and things like that so
00:21:02
um that means that everybody uses wildcard imports four inputs it's when
00:21:06
you import interests and we all know oh well maybe but it's a
00:21:10
it's a common uh thing to say while cut it imports are actually
00:21:14
sloppy a lot of people say don't use the news ninety imports only
00:21:18
and for implicit sleep like that are quite common begin a cavalier attitude to just
00:21:23
about why cut input is that and if if named norman imports are recognisable for
00:21:29
normally members and i've had imports are a problem for normal members and that happens all for implicit
00:21:34
members because implicit i'm much more powerful and global
00:21:38
than normal imports so for normal important just divide
00:21:42
she lack of uh of uh and then got full something like that then i ask better but but that's
00:21:48
that's come from the if i have an an important in in full come up shopping my importance that's fine
00:21:55
uh you know i've had in pork i'm lost i have twos
00:21:58
such a bit further but for implicit it's much worse because this fall
00:22:02
uh could be used anywhere in my program like i don't even seen the application and i
00:22:07
don't see where it comes from and that that leads to the sort of mythical a mystical
00:22:12
uh programming where with the single little switch uh i have a
00:22:16
mode change from now what program and everything either works or it doesn't
00:22:20
uh it also encourages this the simple thing encourages and i'm use that there's a lot of uh
00:22:26
people who have designed libraries that are very powerful
00:22:30
that fundamentally change what your program does and then
00:22:33
it's all a very convenient and camping to just say well just use my brain don't score and
00:22:39
the whole world changes for you call but for the end user that's a problem in particular if
00:22:44
they pull in several libraries that all have this sort of got like execute
00:22:48
and then they have to live with the fall out of the feature interactions
00:22:53
okay so colourful library right 'cause sometimes not so cool for end users of those like
00:22:59
so if you take the criticism together then i think so the historically
00:23:03
impressive started as a way to express conversions and be generalised to be mechanism
00:23:08
to well resolve conversions to provide type classes
00:23:11
extension methods and many other kinds of contextual information
00:23:15
what's amazing is that this simple mechanism it so much
00:23:19
and had so many different use cases so immensely powerful
00:23:22
but the problem is that the mechanism ha tends to hide intent and the over like
00:23:28
it's too much mechanism and not enough intend for the usability in that also
00:23:32
let to the fact that in place it's out positively scary for for a lot of people
00:23:38
in particular people that get dropped into a foreign called code base where they do not know what what kind of interested get used
00:23:45
okay so if you look at the design principles then uh i think we have to sort of come
00:23:51
back and melissa smiling to safely core concept is
00:23:54
term inference that so that uh it is a um
00:23:59
what what's it all about three that beside the the similar to to
00:24:03
yeah we are we know type inference types get inferred from the context
00:24:08
uh would be now have a way to synthesise terms or to infer traps
00:24:14
so that's that's a standard thing and that's sort of the thing that's missing in has still because
00:24:18
it has could these dictionaries are not sure says something so
00:24:21
you do you use some sort of higher order cloud cloud thing
00:24:26
we're buttons got it's very concrete you infer from that you can write down did you that you can
00:24:30
pass explicitly so it's really the missing missing bit yeah
00:24:35
um and how the infrared tremble you give it time
00:24:38
uh that's it that's the type of the time that you want and then you press it search happens and it will synthesise that you're
00:24:46
so um what we want is that instead of adding implicit
00:24:50
as a modify too many different construct allows large test object class
00:24:55
uh and the changing the meaning of each in slightly different ways you
00:24:59
want to have a thing a construct that essentially introduces this principle so instead
00:25:04
of having a modifier with feature interactions for everything we have a single can't
00:25:07
construct that says this is a term that you can infer for this like
00:25:12
and you call these terms after lots of agony and deliberation delegates of delegates its name
00:25:19
so let me introduce delegates so here is the uh probably for
00:25:24
standard first example of a any type class it's bordering with instant list
00:25:29
uh so here we have i'll order to a trade with the compare method which is abstract and less than
00:25:35
and greater than extension methods which uh use these things so that uses another
00:25:39
thing is kind of three extension that's that's which are written like this would be
00:25:43
thing you dispatch on the left upper and it's written to the left of the operate or something
00:25:49
and then you haven't delegate in two or four or above
00:25:52
int where you have to define the abstract method like this
00:25:57
and then you have a delegate for instance let's or which would be the
00:26:01
delegate for order of list of key but for that one you need another
00:26:04
delegate uh and that's passed with the given last given and wondering for order
00:26:09
of key you haven't ordering for list of war but a list of the
00:26:14
i left out the implementation of the compare that so that we will replace implicit
00:26:19
as a modifier and it's very clearly expresses the intent instead of the mic and
00:26:25
some people have to have said well right instances that of the delegate and then it
00:26:29
really looks very much like a pass go to finish and uh the problem was that instance
00:26:36
somebody else and said well no you can't take instance you already took objects to
00:26:40
that that that we talk about these values that the that that are now if you take instances well i'm
00:26:45
i i don't have anything left so you can't use instant stuff uh in the end it was delegate that we
00:26:51
so let me go on a little bit with the uh to to introduce them uh the delegates because i said well
00:26:57
these names of the implicit hang the these times they i
00:27:00
insert automatically so why do the names of these things even nah
00:27:05
i don't think the compiler can synthesise ending so indeed names don't matter
00:27:09
uh you can you can write them a like here which is good for
00:27:14
documentation and it's good for binary stability in debug ability uh that
00:27:19
you say i want this name to be always the same thing
00:27:22
uh then uh that that's fine and or if you want to trace these things
00:27:25
and people go by you know what they call so for these reasons that good
00:27:29
uh but you can if you don't care for that you can also leave them up so you have to delegate for the fun
00:27:35
delegate key for the rest of p. and you can leave
00:27:39
them out from the parameters is just like given and uh pornography
00:27:43
so delegates can be anonymous um if you leave out the name then the compiler
00:27:49
will synthesise ones so for this one here for instance it would would synthesise the name
00:27:54
word underscoring underscore delegate so that would be the principle you would be
00:27:59
work and that's cool is underscored delegates what would only go one level deep
00:28:03
and sometimes you get conflicts because you want to have to delegate service too close together
00:28:08
and yeah and then you give you you give the new stuff but it happens not not that often
00:28:13
okay so um delegates can also be i guess is uh something with that
00:28:19
we have actually the same fundamental power off a origin in place it's uh
00:28:24
so here we would say uh let's say a delegate uh
00:28:27
for execution context global one uh would be a new foregoing pool
00:28:32
uh here we have one position and uh these ideas is kind of course also be conditional so
00:28:38
a delegate for context given an outer contact with us it's the
00:28:42
outer contact with let's say at different all know or something like
00:28:45
that so you can do all these things and the principle of
00:28:49
uh is essentially if that's something you can do with current implicit
00:28:54
a lazy vile an abstract implicit that's over to buy another one and things like that
00:28:59
the guiding principle is is always do exactly that but with normal that was
00:29:04
just use normal to have snow mobiles uh not not implicit so it's actually
00:29:08
you set up a system on one axis and done on the other axes you said well now let me
00:29:13
take this definition and make it in for about using a delegate which isn't often and i guess that like
00:29:19
so instead of saying i can put in place of the modify into everything i say
00:29:23
right it is he did without implicit and and bring it into the term
00:29:27
inference esoteric it's a different principle of organisation but it's it's roughly as calm but
00:29:33
i compact some some things uh uh most things i'm a lot more compact something's out two tokens longer or
00:29:40
things like that it doesn't really matter but it's sort of the uh it it different thing that we say we
00:29:45
separate this idea of setting up an architecture for crime and
00:29:49
making these terms eligible for a type info for term in france
00:29:55
okay um d. uh i you for everything that given class so uh
00:30:00
the design principle for these impressive parameters then
00:30:03
is instead of picking them as normal parameters
00:30:07
you have a separate construct to define and perhaps
00:30:10
uh these impressive parameters and that contact construct loses given
00:30:15
he affords a form in both the application site and
00:30:18
the definitions act so let's see some code of ups
00:30:24
yeah okay so let's see some code uh so we have a a maximum function here
00:30:29
uh and that it's on order and so that's that's the thing here and that's just the maximum
00:30:35
so you can of course call it a bit uh without passing the order and then it will be in for
00:30:41
a from what we had seen before and if you want to pass it then you have to use again given
00:30:47
so next to three given into or to uh is
00:30:50
uh uh passes an explicit ordering and here you have
00:30:54
a for the list if i want to have some of the explicit ordering we can fit given list or
00:31:00
which would be in for the the argument or we can go all the way to to the leaves
00:31:04
and say given into list or given in short so that's how you pass these things it's very explicit
00:31:09
that this is an application of an uh of of of uh
00:31:14
uh uh an implicit parameter so patiently that's the problem with very explicit
00:31:20
and that's important because there is essentially only limited
00:31:24
in place within budget that you asked for usability
00:31:27
so since implicit are already very powerful everything else that surrounds then has to
00:31:32
be stupid to put explicit no no choice allowed because that would just essentially um
00:31:38
uh you i explode your your choice specs so what you can
00:31:42
upright anymore is next to three in torque that would be an or
00:31:46
and for the same reason then you get for free the thing that i showed you before uh this one here
00:31:52
uh uh uh that one uh would of course work because it would say well f.
00:31:58
uh there's no given given so uh if that is the
00:32:00
given a toss a a news news that because a parameter
00:32:04
that would be clear that the u. applies to that thing here and up to that thing over there because if i
00:32:09
wanted to pass something over there i would have had to use a given cost so that's the paper that you get from
00:32:17
okay um
00:32:20
good one that was yeah okay so let's see how it all hangs together doing some type classes
00:32:26
in the new stuff so uh he has to be a a nice thing to do when they began
00:32:31
so here's the uh the set up of the two tried
00:32:34
and then i would say a delegate promenade of spring is uh
00:32:38
i uh uh defined combine as an extension of the uh like this and uh define the unit like this
00:32:46
so this actually works super smoothly and he's actually because of the interaction of extension of
00:32:51
certain places you can see there's a down here in the some uh examples of some
00:32:57
takes a pipe a team that must be a moderate that must have only
00:33:01
been stuns and a list of these ended that then just that followed left off
00:33:05
them on the eve of the unit so that is the same as implicitly but like in shapeless it
00:33:10
gives you the better i could give you the type that in for not the type that was demand
00:33:15
that's all the money that the unit so that would give you the right on it for that
00:33:20
and then you call the combining of that uh so then you pass the combined with that as the uh
00:33:25
function argument that you operate argument to forklift so why does this work
00:33:30
well it works because so take column on it
00:33:33
means we have a minute instance in scope uh
00:33:37
and the rules for extension method say but if you're if you're half height
00:33:44
that has an extension of that like combine and you have an implicit
00:33:47
instance in school for the thing then the extension of that it's applicable so
00:33:53
usually with the tension that that says you have to import them
00:33:56
somehow but we have this is an she typed interaction with interest
00:34:01
and that is a big help because that means you don't have
00:34:03
to use them without any of these things without the decorators and essentially
00:34:08
set up your inflicts operators and things like that all this is gone
00:34:11
it's it's in your type classes itself it works out of the box
00:34:16
okay let's uh just see how that works for hire hundreds of the we're funk or
00:34:21
no not a typical operations but now but now and you're and uh use uh our
00:34:28
uh just worn out that actually defines these show it generalises really lead to higher ranks
00:34:34
okay so not coming back to the origin origin of it all what about the implicit conversions uh
00:34:40
in fact what he proposes to drop implicit conversions as a separate syntactic
00:34:45
constructs so it will be gone like all other uses of templates it's
00:34:49
and what we will keep uh because well uh some people will some
00:34:53
some some softer just demands and does it conversion uh i in in
00:34:58
basically every language has one way to to get to set things up so what we would do is
00:35:03
we will have a standard uh try to ask all conversion a two parameter type class conversion from two
00:35:10
and uh you can uh write a delegate for that type class and that will give
00:35:15
you the conversion so instances uh the delegates or for this type classes are you interested conversion
00:35:21
but he you would one to one from spring to program you
00:35:24
would say well uh it conversion is uh haven't apply method uh
00:35:29
it's a uh so here you can find your prime of the uh to to to to do what it should
00:35:35
do and uh that's the way you set it up the
00:35:37
advantage is that there won't be any more tutorials that say
00:35:42
uh let's start with templates it's and that's that with implicit conversions like they're almost all do today which is
00:35:47
a terrible mistake because we all know it been conversions lead you astray that's it's initiated and for for conversions
00:35:53
uh the you can't do that because conversion that delegates so
00:35:57
before you can explain call buttons you have to explain get it
00:36:00
so by the time hopefully the attention of the the the it's already lower and it comes to comes later
00:36:07
and i thought that's a nice way to do it for as as an idea to like i just for completeness
00:36:11
you can write that again for conversions thing token people's new keyword underscore and that was what uses actually the fact that
00:36:18
conversions of them type a single abstract method type so
00:36:21
that's assigned conversion get technically that you have a function
00:36:24
on that that gets lift it into a single abstract method like so you can write it like that ha okay
00:36:31
and finally uh it let's look at have a look at
00:36:34
the import so instead of importing in places like normal definitions
00:36:38
we wanna have a special construct for them for importing them so here's the uh the
00:36:43
sort of the schematic uh if you have an object and it has
00:36:47
let's say a delegate t. c. and it has a normal a member ah
00:36:53
if i write import aided underscore i will only get the f. i won't get the delegate
00:36:58
and if i write important delegate a dove underscore i will get only get the
00:37:02
data so that would be import p. c. and not have so that is already
00:37:07
data then like we have because now it's clear when we look at the
00:37:11
the code does import delegates they should stick out so you typically will have maybe
00:37:16
fifty important nobody scans them but you might
00:37:19
have only two or three delegate import and uh
00:37:23
those typically the there would be a tendency to just group them somewhere and then you could easily say okay this gets impresses
00:37:29
from here here here so i i don't think that'll be aware of that and i have already formed the picture what is that
00:37:35
uh but we can actually go further because the i did the problem again to say
00:37:41
for delegates for impresses we need by card imports
00:37:45
so that's still that but uh the problem is we
00:37:48
can't use earnings import because names not even less
00:37:51
than before uh names but that it can be anonymous
00:37:55
so you found you cannot you cannot i call them by name but what matters for a delegate
00:38:00
well the pipe right it's hype that's what's matter so what we will uh
00:38:05
what we also have is a way to import delegates fight type so for instance you could have this these the
00:38:11
type that's instances the delegates in or this or you see
00:38:15
for execution context and then i i am for one right
00:38:19
and what you could say an import delegate instances and then you just say for order
00:38:24
underscore so that gives you a essentially everything that conforms to this site which has as its e. kind of
00:38:30
white car so that would give you here in order interest or that's a two delegates that actually match an order
00:38:37
or you could write a a for input delegate instances i am so that's a name one uh you can mix them
00:38:44
and then for execution context and that would import i am by name
00:38:48
and you see like that because he sees you delegate for execution context
00:38:53
so the many improvements in details so delegates implicit parameters can
00:38:58
be anonymous next thing is significant we've seen those shadowing is eliminated
00:39:03
uh the imports coke as being a restricted to not no longer um
00:39:08
uh say jointly impressive scope has been restricted to normal on into package objects
00:39:13
a priority fixation is is a lot more robust it's not
00:39:16
dependent anymore or but you can still be for backward compatibility
00:39:21
you can still use essentially the class directly for that but that and number them better ways to
00:39:25
do it and the error messages have become much better the hardest thing actually was was naming them uh
00:39:33
in fact we went back and forth uh so the design of
00:39:36
uh the delegates has been solid for the last six months about
00:39:40
but uh the the name we went back and forth my region proposal was with that's uh
00:39:45
which uh is sort of a witness for type or that so
00:39:50
in that same context is also evidence for that type so if you know carry howard that's very appealing
00:39:56
most people don't know harry had curry howard and find this very we and so so
00:40:00
that was a lot of push back against that in the end pieces we settled on delegate
00:40:05
and i believe in the end it will not matter so we just need a noun so that we have a name for this class of things we can you
00:40:11
it's only been talking about delegates a lot so that so that is that is sort of a a noun for
00:40:17
uh for a class of concepts uh so that must be a noun and uh it must be easy to remember
00:40:23
so how do we get there uh everything's different now um so uh the
00:40:29
the idea is that the current and that's it i still supported
00:40:32
in the next uh major version of stalin's got a three zero
00:40:36
um uh so uh that means that you can migrate uh at your own pace uh
00:40:42
everything is still there because this of course language implication the language it's
00:40:47
not so bad for the compiler because it turns out that these delegates they
00:40:51
it's actually with all the improvements in the in the polishing that we can by and large map them
00:40:57
delegates in 'cause it's into common concepts uh out in places will probably be separate cages from this kind
00:41:04
of three one on so at some point in places would be deprecated and it would be only delegates
00:41:10
and there's some special provisions made for cross compilation so one uh thing is that
00:41:17
if you want to use given as argument to make it clear that
00:41:20
this is an implicit argument you can use that already with all starting here
00:41:25
it's it's and the other is if you want to use an import delegate to make
00:41:29
it clear that we import want to import delegates that also works with all starting pacific finish
00:41:34
so taken together these two things mean that you can actually migrate user code faster than
00:41:41
a cross compiling libraries so you can keep a library with implicit
00:41:44
for long time on the old ones but you can already pretend
00:41:47
it's in new implicit in the user code and then if most user code has migrated and maybe the library can like right that's fine
00:41:54
okay so you can try this out today dot e. d. w. p. f. l. dot ca
00:41:59
just decides and thank you for listening and uh i think we have time for some questions yeah
00:42:13
hi thanks a lot and your actions make animal comes in like many questions we have enough time
00:42:23
so you can place it's sire is what you actually it's it's it's good
00:42:31
i'm sorry i uh you could imagine does it send delegates distinguish easy you can you can you
00:42:37
can use even stays inside source file that that's normal it so it's just hopeful to support it
00:42:46
oh
00:42:53
thanks is stuff s. s. i. e.
00:42:57
i can still more i mean i'm still i have really
00:43:02
good work e. t. i. e. each word term used x.
00:43:11
yes i enjoy visitor okay so if i had something else all work and like some sort of ah
00:43:20
no that would be a confident with it if it isn't that would yeah okay
00:43:28
which
00:43:31
so i it was nice to still downstairs i'm gonna descriptions
00:43:37
it's all the classes and the notation little doodles structural the and
00:43:43
well that's what feels like we nice well the situation light of
00:43:47
but usually like less and less why not i'm still we don't yeah that's that's
00:43:52
oh we have the the teletext awful the the poverty stuff like each
00:43:57
what's the competition what size a completely with that we we like an additional
00:44:03
some way to express goals with the digits and that's gonna use that and
00:44:08
easy to do what's uh what's what's so you said you want an annotation
00:44:15
on that type to say it's meant to be a type classes that what we
00:44:23
ah okay for the last yeah yeah that that would be in the the um i think that would be very interesting but
00:44:30
i believe we want to we let it play a bit on that because that's a lot of movement and that space and uh
00:44:37
uh so i think don't think we want to standardise too early but uh
00:44:40
i definitely i mean it would be fantastic if we could do more with uh
00:44:44
and then do property based testing or uh or proving that
00:44:49
the that the most or all of them should be prosecuted it's
00:44:53
uh_huh actually there is a sort of i mean the you you can do a lot with ensuring
00:44:59
and requires and this sort of thing so so good this syntactic space for that also with that
00:45:06
i have a question regarding migration yeah and so you will be his uh we use uh
00:45:13
didn't is gonna they still use a period will will mechanisms of you both in uses and delegates
00:45:20
yeah i guess you say can and in the same yeah it would be nice
00:45:25
and the names um uh_huh uh_huh nothing three point one b. only gonna get so
00:45:30
well that i i if what will happen is that um
00:45:35
places will be deprecated in three point one and i believe
00:45:38
state advocated over the whole three psycho because uh we want
00:45:42
to take it's actually back was completed compatibility much more seriously
00:45:46
so that means we can remove them on in for for the zero so that means it will be quite
00:45:51
quite awhile until uh that would stay around but of
00:45:53
course deprecated so openly community will have one person so
00:45:57
we discussed the possibility oh really like tools yes a sense
00:46:02
in loose is ah you describe the mechanism and we do
00:46:06
look easy you describe the tend to think it would be
00:46:10
possible to greet you really to from one to the other
00:46:14
it was the intent to them from the next three days
00:46:18
so so some things are easier than others uh sort of
00:46:21
me already or a half in the compiler rewrite rules for
00:46:25
uh imports uh so the import delegate and and parameters so that
00:46:30
the essentially you just drop in a given in the in the active
00:46:34
so those two things we have to recognise a bunch of impressive
00:46:38
definitions and uh and uh replace them by delegate definition is um also
00:46:45
easy uh as long as you keep it to map only
00:46:49
two ideas delegates and it's pretty straightforward for most of them
00:46:52
if you want it then to collapse into something nicer than uh i
00:46:57
it would be harder it would it would be quite expensive pattern matching from the compiler and probably won't happen
00:47:02
so probably you will just this actually map into something legal and let
00:47:05
me for the user to rewrite it to something nicer the same thing
00:47:16
uh_huh
00:47:18
thank you uh_huh mention mm
00:47:23
uh_huh can mm used balls easy to use you
00:47:29
don't see uh_huh b. b. b. c. e. u.s uh_huh
00:47:35
it's mm mm links like e. o.
00:47:40
does you ah okay yeah yeah that was um
00:47:45
that was a proposition for awhile and it had very strong community support
00:47:50
uh i i believe it would be a mistake because uh it would we would end up with just two more ways
00:47:56
to define and it's it's it would be very confusing to use this thing i mean it is already confusing implicit chatting
00:48:02
being used for in conversions and and parameters and and all
00:48:06
these different things if you add more to the would just add
00:48:10
inside and so so i think it's important to have sandwiches really different uh but even though it's for
00:48:15
for existing users like you are it's it's a big time to get over so first
00:48:20
it looks strange after after a while it looks good will look quite natural it's my prediction
00:48:27
okay um more question an engineer for questions can be handled in the e. doing break okay but ah
00:48:35
okay if it's a short question then yeah

Share this talk: 


Conference Program

Keynote: Some Mistakes We Made When Designing Implicits (And Some Things We Got Right)
Martin Odersky, Professor EPFL, Chairman Typesafe
June 14, 2019 · 9:13 a.m.
303 views
Brave New World - tales of PureScript and Haskell in production
Felix Mulder, Snoop Dogg
June 14, 2019 · 10:22 a.m.
151 views
Lord of the rings: the Spire numerical towers
Denis Rosset, researcher in quantum physics
June 14, 2019 · 1:47 p.m.
Exploring Scala Tooling ecosystem
Jeferson David Ossa, Colombia
June 14, 2019 · 3:12 p.m.
GADTs in Dotty
June 14, 2019 · 4:41 p.m.
302 views
Closing Remarks
June 14, 2019 · 5:49 p.m.

Recommended talks

In Types We Trust
Bill Venners, Artima, Inc
June 12, 2019 · 10:15 a.m.
1569 views