Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Drew Boardman
@drewboardman
alright thanks for helping with this
how would it even be possible to track down the source of an error that has this vague of logging?
it come from "logger_name":"org.http4s.server.middleware.ResponseLogger", but i think that just tells me which logger is outputting the response
all I'm doing with the middleware is applying generic out-of-the-box ones from the lib
  private val middleware: HttpRoutes[F] => HttpRoutes[F] = {
    { http: HttpRoutes[F] =>
      AutoSlash(http) // removes trailing slashes
    } andThen { http: HttpRoutes[F] =>
      CORS(http, CORS.DefaultCORSConfig)
    } andThen { http: HttpRoutes[F] =>
      Timeout(60.seconds)(http)
    }
  }

  private val loggers: HttpApp[F] => HttpApp[F] = {
    { http: HttpApp[F] =>
      RequestLogger.httpApp(true, true)(http)
    } andThen { http: HttpApp[F] =>
      ResponseLogger.httpApp(true, true)(http)
    }
  }

  val httpApp: HttpApp[F] = loggers(middleware(routes).orNotFound)
i'll go take this into that channel
zeroexcuses
@zeroexcuses
Is there a way to download the channel as a log? I tried the search on the LHS but it's not very useful; I'd like some file I can just grep through.
Ross A. Baker
@rossabaker
There's an API and various tools to generate an archive from it. There have been a couple attempts at public archives in the past that raised ire on GDPR grounds. I am neither a lawyer nor a European. If you do it, I didn't endorse it, and please don't share it. But people can and do.
I've had enough success with Google and a site filter where the built-in search fails.
zeroexcuses
@zeroexcuses
Sorry, I did not mean to bring up a sensitive topic -- there was just info of the form "I recall there being a discussion on XYZ, but I can't find XYZ right now."
zeroexcuses
@zeroexcuses
Is cats/scalaz/functiona llibraries useful for "inventing a database" as in https://github.com/papers-we-love/papers-we-love/blob/master/design/out-of-the-tar-pit.pdf . So in particular, I am interested in a style of programming where all data is stored in relational tables (say sqlite3 or h2), but instead of updating the data via SQL, we update the data via Scala.
Ross A. Baker
@rossabaker
No worries, an archive is a thing a lot of people want. Just wanted to note why shared services for that failed.
Rob Norris
@tpolecat
@zeroexcuses cats is useful for any kind of programming; it’s very general-purpose. If you want to do FP you should use it. If you don’t want to do FP you can use Scala like super Java and that also works fine.
Andrew Valencik
@valencik
When going from scala 2.13.4 to 2.13.5 I get unused implicit warning/errors when I try and create an Eq instance for a parameterized type: https://scastie.scala-lang.org/UknDiddWSLul5NTLoMr7zA
Is this a false positive, or am I doing something wrong here?
import cats.Eq

final case class Thing[A](a: A)
object Thing {
  implicit def eqThing[I: Eq]: Eq[Thing[I]] = Eq.fromUniversalEquals
}
parameter value evidence$1 in method eqThing is never used
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
Yeah, you're requesting that there's a Eq[I], but you don't use that knowledge - you delegate to a method that constructs an Eq instance without any knowledge of the underlying type: https://github.com/typelevel/cats/blob/main/kernel/src/main/scala/cats/kernel/Eq.scala#L106
Instead, you can express it using Eq.instance and in it you can use the Eq[I] instance
this thing is a new warning in 2.13.5, which marks unused implicits even if they were synthesized by the compiler (as is the case with I: Eq syntax)
Andrew Valencik
@valencik
Hmmm, ok. So with Eq.instance I would need to define my own (A, A) => Boolean function for equality?
Anton Sviridov
@velvetbaldmime:matrix.org
[m]

in this case you just want to delegate - what does it mean for two Thing[I] to be equal? for their thing.a to be equal.

And you have the Eq[I] instance to compare just the as

implicit def eqThing[I: Eq]: Eq[Thing[I]]

This says "If I know how to check equality of things of type I, I can also check equality of things of type Thing[I]"

You just need to use Eq.instance to wire things together

ah, there's actually Eq.by which is even simpler
implicit def eqThing[I: Eq]: Eq[Thing[I]] = Eq.by(_.a)
something like this
Andrew Valencik
@valencik
Ahhh... this is still a bit unfortunate as Thing here is a big simplification of what I really have, which involves two type params and a handful of other arguments.... any many of them
Thank you though, you've really cleared this up for me :)
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
There's kittens for automatically deriving instances: https://github.com/typelevel/kittens
zeroexcuses
@zeroexcuses
with cats-effects, do we get "pure as Haskell" in the sense that a function can only do effects explicitly stated in it's type signature, or do we get "functional as ocaml/rust" in that functions can do all types of mutations not stated in the signature ?
sinanspd
@sinanspd
there is nothing preventing you from mutating a global variable from inside of an IO
Fabio Labella
@SystemFw
@zeroexcuses the point of IO is not really to statically segregate effects by type, even though you also get that
it's to be able to treat effectful programs as values, which enable compositional apis
in Scala, being as "pure as Haskell" is a matter of discipline, in that there is nothing preventing you from "cheating"
but this isn't as big of a deal as it sounds: cats-effect codebases are as pure as Haskell, in practice
and in a few ways they are better than Haskell since cats-effect IO is more modern than Haskell's
eugene yokota
@eed3si9n
added herding cats day 18, a bit about IO - https://eed3si9n.com/herding-cats/day18.html
zeroexcuses
@zeroexcuses
Does Scala have a concise definition of the type system on the level of "types and programming languages", or does it go the other side of "the implementation is the spec" ?
Martijn
@martijnhoekstra:matrix.org
[m]
The theorectical foundations of scala 3 are called DOT, which was developed from observations of scala 2.
is that what you were asking?
zeroexcuses
@zeroexcuses
In my very limited understanding of type systems, HM inference is fairly straight forward; SML is fairly straight forward, OCaml seems to have added lots of object oriented stuff, Rust is relatively straight forward, Haskell , without extensions is relatively straight forward; as for Scala 2.13, I can't figure out where to place it -- whether there is a "simple core" or whether it has lots of components. This is what I had in mind for "paper" vs "implementation" -- is there a clear theoretical descriptin of the type system, or is it "the implmenetation is the spec"
Martijn
@martijnhoekstra:matrix.org
[m]
Type checking is based on the DOT calculus, which is its own thing, made for scala 3. It has dependent object types and subtyping, which HM doesn't have.
Inference is essentially unspec'ed. The implementation is the spec there. But inference always typechecks
Rohan Sircar
@rohan-sircar

there is nothing preventing you from mutating a global variable from inside of an IO

it's still said to be "pure" right? I'm assuming Haskell does not allow this?

zeroexcuses
@zeroexcuses
Haskell has unsafeIO, though I'm not sure if that is fair game.
Fabio Labella
@SystemFw
that's not fair game imho
btw I wouldn't call Haskell straightforward at this point, the type system is very complicated overall
same with SML and OCaml, the core language is straightforward, but the theory behind modules is very very complex
zeroexcuses
@zeroexcuses
True, maybe I should specify it as Haskell98 w/o extensions -- that, I think, is still straight forward.
Fabio Labella
@SystemFw
yeah, I agree with that, but that language essentially doesn't exist in practice, ~every single library on earth uses various extensions
zeroexcuses
@zeroexcuses

Wait, so is Scala3 fully dependently typed? i.e. can we have type signatures f the form

concat(a: Vec of length M, b: Vec of length N) -> Vec of length (M + N)

?

Fabio Labella
@SystemFw
scala 3 is not fully dependently typed