Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 03:55
    SethTisue edited #1398
  • 03:53
    SethTisue synchronize #1398
  • 02:31

    SethTisue on 2.12.x

    2.12: advance project SHAs (#13… (compare)

  • 02:31
    SethTisue closed #1397
  • 02:31
    SethTisue edited #1397
  • 02:10
    jxnu-liguobin synchronize #9555
  • 01:52
    jxnu-liguobin commented #9555
  • 01:52

    SethTisue on 2.13.x

    fix travis setting. use openjdk… bump sbt version to 0.13.18 Merge pull request #208 from Se… and 4 more (compare)

  • 01:37
    SethTisue commented #1221
  • 01:36

    SethTisue on main

    Update index.md Added a resour… Best Scala Tutorials On YouTube… Merge pull request #1221 from a… (compare)

  • 01:36
    SethTisue closed #1221
  • 01:32
    SethTisue edited #1397
  • 01:31
    SethTisue synchronize #1397
  • 00:54
    SethTisue edited #1398
  • 00:53
    SethTisue edited #1398
  • 00:53
    SethTisue edited #1397
  • 00:51
    SethTisue synchronize #1398
  • 00:49
    SethTisue synchronize #1397
  • 00:43
    harpocrates ready_for_review #9556
  • 00:28
    dwijnand commented #9571
Christopher Davenport
@ChristopherDavenport
As the latter is less compositional.
Peter Aaser
@PeterAaser
Hmm, maybe I should tokenize it
first
Christopher Davenport
@ChristopherDavenport
Likely a good call.
Peter Aaser
@PeterAaser
I mean I did have compiler design back in the day
Christopher Davenport
@ChristopherDavenport
Hard to tell though depending on your case.
Peter Aaser
@PeterAaser
thankfully LALR(1) written in C is not the name of the game anymore :D
Yeh, this is pretty much the first parser I write..
at least asm is pretty easy
Christopher Davenport
@ChristopherDavenport
Here is my cormorant csv parser if that helps at all.
Peter Aaser
@PeterAaser
might be, thanks
Maybe I should read the parser chapter in the red book to get a more fundamental approach
Christopher Davenport
@ChristopherDavenport
I love atto. It's a fun tool.
Peter Aaser
@PeterAaser
How can I cause a parser to fail based on predicate?
Thinking flatMap( x => if(pred(x)) err("reason") else ??? )
Christopher Davenport
@ChristopherDavenport
Failure is one of the options of a parser at any point.
Peter Aaser
@PeterAaser
yes, but I want to have a predicate failure too
I think ok is what I want
Abdhesh Kumar
@abdheshkumar

Anyone has an idea how to override common configuration in included configuration that referenced with environment variable? For example, I have common.conf that has all common configurations and local.conf that override common configurations as per local environment.

common.conf

myapp {
    server-address = ${SERVER_HOSTNAME}
    server-port = ${SERVER_PORT}
}
----------------------
local.conf

include "common"
# override default (Common) settings
myapp {
    server-address = "localhost"
    server-port = 9000
}

while loading local.conf. I am getting below error.

 Could not resolve substitution to a value: ${SERVER_HOSTNAME}
jonathan edwards
@_jedw_twitter
does anyone know what the difference between .contain() and .contains() is?
I believe they are a part of scalatest, but when i search for it I can’t find its definition
the context it’s being used is in this line: items => s"find $itemNum in the available list" >> items.map(_.itemNumber).should(contain(itemNum))
Abdhesh Kumar
@abdheshkumar
@_jedw_twitter contains must be inside scalatest Matchers
Vinayak Pathak
@vinayakpathak

I wasted a day struggling with this:

trait Model {
  type State
}

trait Algorithm {
  val model: Model
  type State = model.State

  def infer: State
}

val m: Model = new Model {
  type State = Int
}

val a = new Algorithm {
  val model = m

  def infer = 1
}

This throws an error:

ScalaFiddle.scala:21: error: type mismatch;
 found   : scala.this.Int(1)
 required: $anon.this.State
    (which expands to)  $anon.this.model.State
    def infer = 1
                ^

I stared at the longest time on the definition of val a because that's where the error was coming from, but eventually realized the cause was my definition of val m. If I remove the : Model and make it val m = new Model {...} it works.

Abdhesh Kumar
@abdheshkumar
@_jedw_twitter here you could find more about matchers http://www.scalatest.org/user_guide/using_matchers
Fabio Labella
@SystemFw

If I remove the : Model and make it val m = new Model {...} it works.

yes

when you do : Model you remove the refinement
which is inferred otherwise
it should bem: Model {type State = Int }
Vinayak Pathak
@vinayakpathak
yeah that's interesting
Fabio Labella
@SystemFw
you can look into the Aux pattern as well to see a shorthand
which is very commonly used in the shapeless world
Vinayak Pathak
@vinayakpathak
yeah I've seen the Aux pattern
Fabio Labella
@SystemFw
same thing, m: Model.Aux[Int]
I'd recommend using existentials only when you need them though
Vinayak Pathak
@vinayakpathak
if I had chosen to implement Model as trait Model[State] though, I would've been notified about the error at the line val m: Model = new Model[Int] {...} coz there would be a missing type parameter
Fabio Labella
@SystemFw
well : Model is a valid type there, so there's no error
the error is when you try to unify it with Int later
Vinayak Pathak
@vinayakpathak
ummm why is Model valid
Fabio Labella
@SystemFw
do you need State to be existential there, since you are already making the whole Model existential in Algorithm?
Vinayak Pathak
@vinayakpathak
i'm not sure what existential means
Fabio Labella
@SystemFw

ummm why is Model valid

Because scala allows you to have abstract (existential) types

well, replace that word with "abstract"
scala allows you to have abstract types
Vinayak Pathak
@vinayakpathak
oh i see ok
ok then i'm not sure when one would need a type to be existential as opposed to just a type parameter
Fabio Labella
@SystemFw
the two things, type parameters and abstract types (universals and existentials) are two different ways to enforce information boudaries
jonathan edwards
@_jedw_twitter
@abdheshkumar Thanks man, I guess i wasn’t reading enough of the page.
Fabio Labella
@SystemFw
well, one use case is to hide the specific type used there
for example, imagine List[Algorithm]