Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 13:32
    julienrf commented #2169
  • 13:31
    julienrf edited #2206
  • 13:29
    julienrf review_requested #2206
  • 13:29
    julienrf review_requested #2206
  • 13:29
    julienrf opened #2206
  • 12:05

    julienrf on main

    Update union-types.md // scrip… Merge pull request #2180 from d… (compare)

  • 12:05
    julienrf closed #2180
  • 11:59
    bishabosha commented #2205
  • 11:55
    julienrf unassigned #2205
  • 11:55
    julienrf commented #2205
  • 09:01
    bishabosha assigned #2205
  • 09:01
    bishabosha unassigned #2205
  • 09:01
    bishabosha commented #2205
  • 07:53
    lrytz milestoned #12474
  • 07:53
    lrytz labeled #12474
  • 07:53
    lrytz labeled #12474
  • 07:50
    julienrf assigned #2205
  • 07:50
    julienrf unassigned #2205
  • 07:50
    julienrf commented #2205
  • 03:00
    som-snytt commented #504
trepidacious
@trepidacious
I should read up on the data constructor thing, but approximately Just and Nothing are ways of getting a value of type Maybe, but that does not make them types themselves?
Jose C
@jmcardon
you can
Option is essentially Either with less information
Fabio Labella
@SystemFw
@trepidacious yes
Jose C
@jmcardon
you discard the information on the left parameter
Fabio Labella
@SystemFw
Some and Nothing do two things
Jose C
@jmcardon
and you can implement option
trepidacious
@trepidacious
Sorry of type Maybe a I guess
Fabio Labella
@SystemFw
one) they construct values of type Maybe a
two) they are runtime tags that are used to do runtime dispatch (pattern matching)
trepidacious
@trepidacious
@SystemFw So in Scala terms a constructor and an unapply?
Fabio Labella
@SystemFw
yeah
well, they literally are tags
that are part of the runtime representation
trepidacious
@trepidacious
Like in a tagged union?
Fabio Labella
@SystemFw
kind of like python "types"
yes, pretty much
trepidacious
@trepidacious
Thanks that's much clearer, I would probably have tripped over that later :)
Fabio Labella
@SystemFw
types are compile time labels that are used to statically prove the absence of certain behaviour
tags are runtime labels that inform you about a specific data representation in memory
when python (or any other "strongly typed" untyped language) programmers talk about types
those aren't types, they are tags
trepidacious
@trepidacious
I guess they are kind of types if the set of behaviours you check for is empty ? ;)
Fabio Labella
@SystemFw
well, you jest
but one view of untyped languages
trepidacious
@trepidacious
Vacuously typed! It's the new thing :)
Fabio Labella
@SystemFw
is that they are actually unityped
so, everything has one type (e.g Object or whatever), with lots of tags (Int, String, Dict or whatever)
btw this is loosely related to the class vs type distinction in OO
trepidacious
@trepidacious
I've never completely got that, beyond "a class is one way of defining a type"
Fabio Labella
@SystemFw
well, no
it's similar
the type is the compile time entity
the class is the runtime tag (a bit loose here cause I don't really bother with OO theory)
there's a really nice article though
wait a min
but basically when you pattern match on an Option you are checking to see if a value of type Option[A] has class Some or None
the problem is that most OO languages mingle these two aspects
trepidacious
@trepidacious
But Some and None are also types?
Rich
@Rich2
I've long thought that "objects" in "object orientated" are misnamed. They usually mean smart objects that have self knowledge as opposed to dumb data. Smart object is a bit of an oxymoron.
Fabio Labella
@SystemFw
so Some defines both a type Some and a class Some
trepidacious
@trepidacious
Yup
So every class defines a type, but not every type is a class
Fabio Labella
@SystemFw
from the article:
All of this is simply to say that we must be working with two separate concepts here.

The runtime shape and properties of the values that end up flying around when a program actually runs. This we call class.
The compile-time, statically-discoverable shape and properties of the expressions that fly around when a program is written. This we call type.
which should resonate (with some differences) from the talk about types and tags
trepidacious
@trepidacious
My opinion on OO is probably completely facile, but I really think the good bit is syntactic sugar and name-spacing, everything after that is normally a bad idea
@SystemFw Yes the compile-time / run-time distinction definitely makes sense
Rich
@Rich2
Pattern match on AnyRef should be a different function to a match on an Int or or Double. I don't think they should even have the same syntax.
Jose C
@jmcardon
omg
what on earth is happening with gitter
@SystemFw same thing in the scalaz room now