These are chat archives for evhub/coconut

17th
Mar 2017
Julian Ospald
@hasufell
Mar 17 2017 12:17
It seems ADT can be made iterable very easily. Wouldn't it be interesting to make that default? E.g.
data Mydata(foo, bar):
    def __iter__(self):
        for i in self._fields:
            yield getattr(self, i)
Proabably not, but still very neat.
Julian Ospald
@hasufell
Mar 17 2017 12:33

also, would be nice if we have an equivalent of RecordWildCards, so you could do something like:

data Mydata(foo, bar)

foo = 1
bar = 2

new_data = Mydata({..})

Filling in foo and bar automatically to contruct Mydata

Julian Ospald
@hasufell
Mar 17 2017 13:20
Also, linebreak with long compositions doesn't work
   foo
|> bar
|> baz
|> bup
that should be allowed and work
Evan Hubinger
@evhub
Mar 17 2017 19:37

@hasufell ADTs actually already support iteration--try iterating over them! As for linebreaks, line continuation in Coconut is done exactly as in Python, using parentheses (or brackets or braces):

(foo
 |> bar
 |> baz
 |> bup)

As for Record Wild Cards, that's an interesting thought--can you raise an issue describing specifically the syntax you'd want to see?

Julian Ospald
@hasufell
Mar 17 2017 21:16
@evhub I tried iterating over them via tuple(obj) it didn't work
Evan Hubinger
@evhub
Mar 17 2017 23:00
@hasufell In the interpreter, I get:
>>> data Data(a, b)
>>> d = Data(1, 2)
>>> tuple(d)
(1, 2)