jeapostrophe
2017-5-10 16:54:49

Schrödinger Error: Add a printf and the error is not there. Remove it and it is.


jeapostrophe
2017-5-10 16:59:14

Update Racket and the error is gone


jeapostrophe
2017-5-10 16:59:23

Excellent service Matthew, fix the error before I report it :)


jeapostrophe
2017-5-10 17:14:25

actually, I just have the error in a different place now


thinkmoore
2017-5-10 17:31:53

tricky implementation question: I have a module that exports some syntax. In certain contexts, this syntax acts as a value. I’d like that value to have a contract attached to it, but I can’t figure out the right way to make my syntax play nice with the contract system’s module boundaries. the easy solution would be to define/contract the value that the macro expands to in my server module, but that isn’t the boundary I want.


bmastenbrook
2017-5-10 18:04:47

Really stupid question time: has anyone used net/smtp and net/qp or net/base64 together?


bmastenbrook
2017-5-10 18:05:39

I’m trying to send a message, but net/smtp wants a list of lines, and it looks like the latter two encoding libraries produce a single bytes with internal CRLFs


georges-duperon
2017-5-10 18:06:57

@leif I have on my TODO list the goal to upload code coverage results automatically (via the Travis script). I’ll remember to give you a ping if/when I implement the script.


jeapostrophe
2017-5-10 18:07:24

thinkmoore: there’s something in syntax/parse’s experimental libraries that does that, forget its name



thinkmoore
2017-5-10 18:37:06

@georges-duperon thanks! that looks like exactly what I need


leif
2017-5-10 18:38:12

@georges-duperon Oh cool, yes, please do. :slightly_smiling_face:


bmastenbrook
2017-5-10 18:39:16

It looks like - despite the documentation - handing a list containing the byte string produced by base64-encode to smtp-send-message works fine.


bmastenbrook
2017-5-10 18:39:16

reply_broadcast messages not yet supported


notjack
2017-5-10 18:40:30

Somewhere buried in my laptop is a work in progress package that provides base64 encoding with more options to support all the weird variations of base64


bmastenbrook
2017-5-10 18:41:04

What’s there seems to work just fine for my purposes


thinkmoore
2017-5-10 19:08:37

or rather, wrap-expr/c is almost what I want but seems to cause the blame to be swapped


lexi.lambda
2017-5-10 19:09:30

@thinkmoore what version of Racket?


thinkmoore
2017-5-10 19:09:41

6.9.0.2


lexi.lambda
2017-5-10 19:10:22

hmm. I flipped the wrap-expr/c blame in 6.9, which IME is the Right Thing


lexi.lambda
2017-5-10 19:10:32

but maybe that was a bad idea


thinkmoore
2017-5-10 19:10:55

let me try it with a small example


lexi.lambda
2017-5-10 19:12:12

I’m surprised I didn’t add an @history annotation :/


lexi.lambda
2017-5-10 19:14:39

@thinkmoore: it sounds like you’ve hit the pathological case. wrap-expr/c is really intended to be used on macro arguments, but in older versions of Racket, the blame was not configured properly for that use case.


lexi.lambda
2017-5-10 19:15:04

but in your case, it sounds like you want definition-like blame, which is the old behavior.


thinkmoore
2017-5-10 19:15:10

just saw that from playing with it in a small example… i’m trying to use it for a macro result unfortunately


thinkmoore
2017-5-10 19:15:18

seems like it should have an option


thinkmoore
2017-5-10 19:15:21

or two versions


thinkmoore
2017-5-10 19:16:00

(i’m implementing something akin to your multimethods implementation, but where methods have contracts)


lexi.lambda
2017-5-10 19:16:08

probably adding an argument to wrap-expr/c is the right thing to do. I considered doing that when I changed it, but I decided I didn’t know enough to know what the interface should be.


lexi.lambda
2017-5-10 19:16:35

that use case can probably motivate exactly what the argument should be like.


lexi.lambda
2017-5-10 19:17:33

I would love to discuss this further, and I can also show you a workaround, but unfortunately I have to go, and I won’t be able to get back to this until late tonight.


thinkmoore
2017-5-10 19:18:02

I can deal with the weird error messages for now


thinkmoore
2017-5-10 19:18:07

talk to you later


lexi.lambda
2017-5-10 19:19:05

if you look at the implementation of wrap-expr/c, you’ll find a contract combinator in the same module called blame-swapped/c or something like that.


lexi.lambda
2017-5-10 19:19:58

if you just inline that into your code and apply it to your contracts, it will cancel out with the one inside wrap-expr/c, and you’ll get the blame you want.


georges-duperon
2017-5-10 19:29:52

@thinkmoore you might want to have a quick look at https://github.com/jsmaniac/polysemy which I published today. The online docs haven’t been built yet, so you’ll need to install it locally to read them till tomorrow. polysemy allows defining identifier overloads. The first example in the docs defines ^ as a lexical token for a macro (a.k.a what you would normally use {~literal ^} for), as the exclusive or match expander, and as two function overloads (one on numbers, which does expt, and one on booleans, which does xor). The four “meanings” are defined in four separate modules, and imported seamlessly without causing conflicts. The goal of polysemy is to allow independent definitions of different meanings for identfiers (type, match expander, macros, function overloads, …), and to allow renaming the parts independently (to split or recombine meanings of one or more identifiers). For now the function overloads are single-dispatch, though, because it’s just a proof of concept.


georges-duperon
2017-5-10 19:30:39

@thinkmoore I’m more interested in the renaming / independent definition part than the multiple-dispatch part, but the latter is definitely something which I want to add later if the approach I took seems viable.


thinkmoore
2017-5-10 19:30:59

that sounds really interesting!


thinkmoore
2017-5-10 19:31:52

my current issues are about wanting to use a single id for both the method itself as a value, and as a carrier of compile time info


thinkmoore
2017-5-10 19:32:33

so that you can do (some-op with-some-args) but also (define-instance (some-op ….) …), where some-op has the necessary info to check various properties of the instance at compile time


thinkmoore
2017-5-10 19:32:49

which it sound like polysemy might help with


georges-duperon
2017-5-10 19:35:44

@thinkmoore what sort of properties do you try to check? Also, I suppose define-instance uses “instance” in the haskell way, toughly (so here it would define an overload for some-op which accepts the given arguments)?


thinkmoore
2017-5-10 19:38:28

it checks that the arities are the same, and that the instance dispatches on the the same number/position of arguments, and it also checks that there are no possible ambiguities (i only allow dispatch on a special class of struct-like things, so I know the possible subtyping relationships)


georges-duperon
2017-5-10 19:45:13

@thinkmoore In polysemy I’m only checking that there are no ambiguities, based on the subtyping relationship (I hard-coded it for a few contracts for now, structs are not handled). The implementation mechanism is a bit crude: it uses a global hash table to track the possible overloads, and then checks at compile-time, when the id is used, that for the set of overloads which are defined for this id do not overlap. The advantage is that I do not have the restrictions that @lexi.lambda’s multimethods have, namely that one of the dispatched-on types must be defined in the same module as the implementation. Also, there is no need for a centralized declaration of the method identifier.


georges-duperon
2017-5-10 19:46:40

The drawback is that it relies on name mangling: since require and provide only handle plain names, without anything like macro scopes, I simply define each overload using a mangled name, and the “main” identifier does a look-up when it is used.


thinkmoore
2017-5-10 19:49:58

sounds about the same, except that with multiple dispatch checking gets a bit hairy, so i wrote a little racklog program that both implements the dispatch and lets me query for ambiguities


georges-duperon
2017-5-10 19:50:49

Also, the overloads which can exist at the same time at a given point are more restricted: (foo TypeA Any) and (foo Any TypeB) cannot co-exist, because they overlap (whereas with @lexi.lambda’s restrictions, they could co-exist as long as they are defined in the right way). So we have different trade-offs, and I’m curious about the implications of each approach in practice.


georges-duperon
2017-5-10 19:51:47

@thinkmoore Ooh, racklog… sweet :slightly_smiling_face: that’s a very nice idea (as long as you don’t hit a pathological case performance-wise, sigh).


thinkmoore
2017-5-10 19:52:24

yeah… haven’t profiled it yet, but since I :heart: logic programming I thought I’d give it a go….. >.> <.<


thinkmoore
2017-5-10 19:53:17

ah, that’s the kind of overlapping I check for


georges-duperon
2017-5-10 20:02:33

@thinkmoore One thing that I want to add later is the ability to have macro overloads (multimacros, if you will). As long as the syntax which they accept do not overlap, it should be allowed to define “the” macro in several separate modules. I’m half convinced that this could be cool, and half convinced that this could be a terrible idea :slightly_smiling_face: .


lexi.lambda
2017-5-11 06:20:54

:ie: @thinkmoore, @georges-duperon: FWIW, my multimethods impl is basically a toy, and I would happily cede the package name to a better package. My bet is that nobody actually depends on that package.