Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 15 19:04
    NthPortal review_requested #9786
  • Oct 15 17:20
    Kordyjan commented #1284
  • Oct 15 17:14
    Kordyjan synchronize #1284
  • Oct 15 17:13
    Kordyjan opened #1284
  • Oct 15 16:31
    som-snytt commented #12473
  • Oct 15 15:22
    NthPortal commented #12473
  • Oct 15 15:18
    NthPortal commented #12473
  • Oct 15 15:16
    NthPortal commented #12473
  • Oct 15 15:15
    NthPortal commented #12473
  • Oct 15 15:11
    NthPortal commented #12473
  • Oct 15 14:49
    ches commented #12378
  • Oct 15 13:15
    bishabosha edited #2205
  • Oct 15 13:15
    bishabosha assigned #2205
  • Oct 15 13:14
    bishabosha review_requested #2205
  • Oct 15 13:14
    bishabosha review_requested #2205
  • Oct 15 13:14
    bishabosha opened #2205
  • Oct 15 11:15

    bishabosha on main

    simplify sbt cheatsheet eliminate we from scala 3 guide implement suggestions and 8 more (compare)

  • Oct 15 11:15
    bishabosha closed #2202
  • Oct 15 02:06
    SethTisue commented #10831
  • Oct 15 02:06
    SethTisue closed #10831
PsyfireX
@PsyfireX
Would you consider this mutation?
Seq(3) ++ Seq(4)
Josh
@joshlemer
No not typically
I would say almost certainly no
Martijn Hoekstra
@martijnhoekstra
@joshlemer what's in our language is scala - creating a binding like val x = 12345. Your interpreted language is the language with the primitives defined asAssignmentTo, interpreted by the function in the fold -- only when you give AssignmentTothe meaning of being a program, then the mutability shows up.
PsyfireX
@PsyfireX
Would you consider this mutation (from your example)
acc + ((ident, newValue))
Martijn Hoekstra
@martijnhoekstra
but then it's also clear what the dividing line is -- the language of AssignmentTo
Amit Prasad
@amitprasad01_twitter
@joshlemer I'm not able to create the object of a class which is injected in my testing module
Josh
@joshlemer
@martijnhoekstra what makes AssignmentTo a language any more than Option or Either?
Fabio Labella
@SystemFw
@joshlemer your code is referentially transparent. Purity is defined as referential transparency, there's no ambiguity there
Matthew Pickering
@mpickering
I am wondering about the internal design of the scala compiler. Is it correct that each phase of the compiler is a function which takes a CompilationUnit as an argument? In this case, what does the typer phase do? Does it mutate this value and add typing information? Is there any static guarantee that certain phases initialise certain fields?
Fabio Labella
@SystemFw
Option or Either are also "languages" (effects)
also, and I feel like this is getting lost: mutation ≠ impurity
referentially transparent mutation is pure
by definition
your language is a Free monoid (a List) of commands, where each command describes assigning a value to something
it's perfectly referentially transparent (pure), because the definition that defines purity (replacing an expression by its bound value doesn't change behaviour), holds
Martijn Hoekstra
@martijnhoekstra
@mpickering scalac parses source code to syntax trees. In subsequent phases more information is added to those trees. The typer phase hangs types on the trees
it's all very Christmasy
Matthew Pickering
@mpickering
but it is all dynamically typed yes?
Fabio Labella
@SystemFw

I see your exmple, but what you did was show that you can interpret an impure language in a pure interpreter. Just because you can use pure programming to write an interpreter to interpret an impure program doesn't make the interpreter impure.

So, in the example, neither the language or the interpreter are impure, at all

Harrison Houghton
@hrhino
It's statically Trees. Most trees wind up with tpe (and symbol, if it makes sense) set after typer.
Some Tree subclasses don't show up before or after certain phases.
so it's pretty loosey-goosey like that.
Matthew Pickering
@mpickering
ok
Martijn Hoekstra
@martijnhoekstra
to the compiler, the types of your program are values, the types of your program are not types in the compiler
Matthew Pickering
@mpickering
@martijnhoekstra Yes but you can design a compiler so that the type of a typechecked AST is different to that of a parsed AST.
Harrison Houghton
@hrhino
Yes, ghc does that, for instance.
Martijn Hoekstra
@martijnhoekstra
it depends on who you mean by "you" -- if you mean me, then no :P
Harrison Houghton
@hrhino
Their tree is parameterized over the "name" type, which goes from RdrName (scalac's Name) to Name (a tuple of name/symbol/type) during typechecking.
Matthew Pickering
@mpickering
I was trying to understand how plugins could possibly work but now it makes sense
As I understand it though, the "parser" phase always has to come first because that takes a string as an argument rather than a CompilationUnit.
But https://github.com/non/kind-projector claims to extend the syntax?
Seems to actually run after parsing so doesn't extend the syntax
Martijn Hoekstra
@martijnhoekstra
it probably hooks in to the names it considers special
Harrison Houghton
@hrhino
Kind projector doesn't actually extend the lexical syntax
it's all "valid scala" before it runs
Martijn Hoekstra
@martijnhoekstra
valid scala syntax that is
Harrison Houghton
@hrhino
it changes the meaning of certain trees like Const[A, ?]
Right
Matthew Pickering
@mpickering
right, that's how I imagined it actually worked but the plugins page seemed to suggest otherwise
I'm less interested now :P
Harrison Houghton
@hrhino
haha
there's a lot you can do by manipulating parsed-but-not-yet-typed trees.
Martijn Hoekstra
@martijnhoekstra
Maybe I can interest you in a lovely pre-owned sausage maker
Matthew Pickering
@mpickering
Are there any mechanisms to affect type checking? To make more programs compile than would otherwise? (But not by hacking around in the parser <-> renamer phase)
Harrison Houghton
@hrhino
There's AnalyzerPlugin.
That lets you adjust the types of trees.
You can't completely replace typechecking (nor, I think, can you suppress type errors), though
Matthew Pickering
@mpickering
thanks, useful to know