Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 10:34
    smarter commented #8643
  • 10:34
    smarter commented #8643
  • 10:07
    lrytz commented #8643
  • 09:59
    lrytz commented #8643
  • 09:59
    lrytz commented #8643
  • 09:12
    dwijnand synchronize #9613
  • 09:11
    lrytz commented #12380
  • 09:04
    lrytz commented #12380
  • 08:52
    unkarjedy commented #11877
  • 07:35
    KisaragiEffective opened #2004
  • 07:33
    dwijnand synchronize #9613
  • 05:13
    griggt commented #12280
  • 05:05
    SethTisue commented #12273
  • 05:05
    SethTisue commented #12273
  • 05:04
    SethTisue commented #12273
  • 04:55
    jxnu-liguobin commented #12280
  • 03:12
    SethTisue commented #12273
  • 03:11
    SethTisue commented #12273
  • 03:10
    SethTisue commented #12273
  • 02:59
    SethTisue commented #12273
Fabio Labella
@SystemFw
iirc when they actually tried to implement HKT that way they hit enough blocks that they had to settle for a direct representation of them instead
trepidacious
@trepidacious
Just looking at https://bartoszmilewski.com/2015/01/20/functors/ challenge 1, and I think that it IS a functor, but I also feel that must be wrong...
Also I can't find a complete set of answers, if there isn't one I could maybe put my answers up to be corrected :)
Fabio Labella
@SystemFw
have you read about the Functor laws?
(it's not a Functor btw)
@trepidacious
trepidacious
@trepidacious
@SystemFw Yup, preserving identity and composing? This makes me think I'm doing it wrongly ;)
Fabio Labella
@SystemFw
yeah, what does the identity law say?
Martijn Hoekstra
@martijnhoekstra
identity is fa.map(a => a) == fa
Fabio Labella
@SystemFw
yep, fmap id = id
then, with the definition in the challenge
Some(1).map(a => a) = None
Jose C
@jmcardon
btw what's the status of opaque types in good ol' dotty
or even in scala 2.13
Fabio Labella
@SystemFw
so defining fmap _ _ = Nothing breaks the identity law (haven't checked composition, but it doesn't matter, we've already seen it's not a Functor)
Martijn Hoekstra
@martijnhoekstra
the opaque types SIP is still pending. If the last SIP meeting was the December meeting, it hasn't been discussed yet
Jose C
@jmcardon
rip that's probably the SIP that I care the most about right now
trepidacious
@trepidacious
@SystemFw Ah yeah I was thinking that since _ => Nothing is the identity of Nothing it was enough, but I guess that is only enough if the type constructor was to Nothing, rather than to Maybe?
Fabio Labella
@SystemFw
see, Nothing can't be a type constructor
Jose C
@jmcardon
because opaque types being 0-cost with no .asInstanceOf casts would be so good
Fabio Labella
@SystemFw
that's where Scala is a bit weird
because Some and None have their own types
but the Functor is for Option
Martijn Hoekstra
@martijnhoekstra
it was on the agenda for last SIP meeting, but it got postponed @jmcardon - I don't know when the next SIP meeting is scheduled. Ask Jorge if you see him about.
trepidacious
@trepidacious
@SystemFw Yes it's the fact that the type constructor is Maybe that I was missing, I was kind of assuming that everything was Nothing ;)
Fabio Labella
@SystemFw
in Haskell is a bit clearer because Just can not be a type (I'm ignoring DataKinds ofc, but even in that case it's not the same)
Jose C
@jmcardon
:(
ok
thanks @martijnhoekstra
Fabio Labella
@SystemFw
yeah, Just and Nothing aren't types in Haskell at all, just constructors whose result has type Maybe a
Jose C
@jmcardon
Benching stuff, it's pretty nutty that .asInstanceOf casts can be equally expensive or more than creating a new object in the heap, as far as runtime is concerned
trepidacious
@trepidacious
@SystemFw And Nothing isn't a type constructor because it has no type parameter, whereas Const is, even though the type parameter does nothing?
Fabio Labella
@SystemFw
no
that's not the reason
data Maybe a = Just a | Nothing
the stuff to the right of = is data constructors, not types
Jose C
@jmcardon
yeah
you can't have stuff return Just I think
only Maybe
Fabio Labella
@SystemFw
in Scala you have a hierarchy of types/classes
in Haskell you have a type with variants
Just and Nothing are two things
trepidacious
@trepidacious
@SystemFw Ah ok, that makes sense. Even in Scala though None wouldn't be a type constructor because it is just a type?
@SystemFw Whereas Some actually is?
Jose C
@jmcardon
yeah
you can see it in the signature
Fabio Labella
@SystemFw
right, the important distinction here is not between type and type constructor
that doesn't matter
Jose C
@jmcardon
object None extends Option[Nothing]
Fabio Labella
@SystemFw
it's between type constructor and data constructor