ChanServ changed the topic of #elliottcable to: drugs
Sgeo has joined #elliottcable
cloudhead has quit [Ping timeout: 240 seconds]
yorick has quit [Remote host closed the connection]
<whitequark>
alexgord_: ooooh that's a hot topic with ocaml
<whitequark>
I mean you wish you could extend sum types
<whitequark>
but the problem is, sane pattern matching requires exhaustiveness analysis, meaning if you can arbitrarily extend enums, it kinda loses half of its good quantities
<alexgordon>
whitequark: I was thinking about this
<whitequark>
if you don't have a subtyping relationship between them, it's fine
sharkbot has quit [Remote host closed the connection]
<whitequark>
or pointers to them
Determinist has joined #elliottcable
<alexgordon>
ah
sharkbot has joined #elliottcable
<alexgordon>
90% of the time, I pass in an enum as a value to a function
<alexgordon>
enum constant
<alexgordon>
possibly in some kind of bitmask
<alexgordon>
I don't think enums have to be fancy :P
<whitequark>
well sure then
* alexgordon
leaves the big problems to the big french brains @ ocaml
<whitequark>
well, this wouldn't work in ocaml
<whitequark>
because if you have Top, it doesn't have a well-defined type
<alexgordon>
which line?
<whitequark>
could be either EdgeAlignment or BoxAlignment.
<alexgordon>
oh
<alexgordon>
well it *does* because it's BoxAlignment
<whitequark>
no
<whitequark>
expression "Top" doesn't have a well-defined type
<alexgordon>
yeaaaah but you can bend the rules a little for a constant expression like this
<whitequark>
yes. it also comes in useful for, say, integer literals
<alexgordon>
enums have few if any operations on them
<whitequark>
one: pattern matching :p
<alexgordon>
usually you either put it into a variable of a specified type, or you pass it to a function argument of a specified type
<whitequark>
type inference
<whitequark>
but, yeah, without global inference, it's possible to make that generic-literal trick
<whitequark>
in some cases you would be forced to explicitly annontate what type you want there, though. that's sad.
<alexgordon>
not really, if it's only the minority of cases
<whitequark>
e.g. in ocaml (and other langs with ML inference) you can write any expression without mentioning types explicitly even once*
<alexgordon>
as long as the compiler errors out and it's well specified, I don't see a problem making the programmer specify a type if it's not absolutely clear
<whitequark>
* unless 1) you use modules for separate compilation 2) you use GADTs, but GADTs are a special kind of evil
<alexgordon>
I think you're overthinking
<whitequark>
e.g. match Top with Top | Bottom -> true | Left | Right -> false
<whitequark>
wouldn't compile as is
<alexgordon>
whitequark: but you don't usually see code like that
<alexgordon>
more often you have
<alexgordon>
instead of matching on Top you have an argument whose type is specified by the function's type signature
<whitequark>
sure
<whitequark>
it's more of an elegance argument than practicality one
<whitequark>
could also affect generated code.
<alexgordon>
but are you thinking that enums are objects?
<alexgordon>
if Top is a 0 whatever its type, then there's no problem, no?
<whitequark>
uh
<whitequark>
wat?
<whitequark>
then it's not enums, then it's constants with integer values
<whitequark>
and you don't have type safety for them, which is obviously a shitty idea
<alexgordon>
lol no, I'm not saying it shouldn't be typechecked
<whitequark>
ok, so
<whitequark>
in the match above the problem is not in the lhs part ("Top")
<whitequark>
it's just that type of lhs is not well-defined
<whitequark>
the problem is in exhaustiveness check of the rhs part
<alexgordon>
ah I see
<alexgordon>
I still don't think it's that much of a problem
<alexgordon>
because you would always have some explicit type information for the thing you're matching on
<alexgordon>
depends on how much inference the language allows I guess
<alexgordon>
I could see it being a problem in Haskell, but not in Java
<whitequark>
hm?
<whitequark>
explicit type information?
<whitequark>
see the example above, it would translate almost identically to even Java
<whitequark>
switch(Top) { case ...:
prophile has quit [Quit: The Game]
prophile has joined #elliottcable
prophile has quit [Quit: The Game]
gozala has quit [Quit: Connection closed for inactivity]
alexgord_ has quit [Quit: Computer has gone to sleep.]
alexgordon has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
eligrey has quit [Quit: Leaving]
<glowcoil>
whitequark: haha gadts are a special kind of evil?
<whitequark>
well
<whitequark>
they have a pretty high WTF factor
<glowcoil>
they've always seeed off to me but it seems like you'd know more than i do about how they interact iwth shit
<glowcoil>
what happens that's WTF?
<whitequark>
well, you see, GADTs is basically
<whitequark>
simply-typed lambda calculus in a box
<whitequark>
it's a tool for embedding languages closely based on simply-typed LC
<whitequark>
and in fact, quite a few problems can be reduced to that
<whitequark>
but the problem is, if you need to deviate from whatever rigid idea your GADT typechecker has about correctness, you're *fucked*
<whitequark>
let's say that I do not consider myself to be really dumb and I studied PL theory for 2+ years, yet when I tried to use GADT for exactly the thing GADT was supposed to be used, I utterly failed
<whitequark>
it was in ocamltrader we were writing with devyn
<whitequark>
I fucked with GADTs for two weeks, trying to encode a DSL in a type-safe way
<whitequark>
I've consulted no less than three people on #ocaml, some of which worked on the language itself
<whitequark>
well, in the result, I got nothing
<glowcoil>
whitequark: mm
<whitequark>
basically I got stuck when I wanted to express a function with signature forall a. a -> a t (for example) in that GADT framework
<glowcoil>
yeah it seemed like an arbitrary addition of power that didn't really do enough
<glowcoil>
or whtadver
<glowcoil>
whatever*
<glowcoil>
also phantom types seem kind of icky
<whitequark>
it seems to be possible, but in some very specific set of circumstances
<glowcoil>
what does that function type mean?
<whitequark>
and basically I tried for weeks to figure out how to do it, but all I got was extremely confusing type errors
<whitequark>
well
<whitequark>
think packing an arbitrary scalar in a container
<whitequark>
"t" is a container type with a single parameter
<glowcoil>
oh oh oh ocaml has backwards type-application syntax from haskell's
<whitequark>
right
<glowcoil>
i was thinking, if a is * -> * then how the hell can it be an argument
<glowcoil>
haha
<whitequark>
"int list array" kinda reads well
<whitequark>
opposed to "array list int", say
<whitequark>
though I don't really buy this argument :p