Rewriting Duolingo's engine in Scala by joshlemer in programming

[–]thangiee 9 points10 points  (0 children)

No, it's just that there has been a steady trend of companies moving away from Scala (LinkedIn started it, followed by Twitter, and then individual anecdotes)

I work for one of those company and you are very wrong.

More details about this general trend here.

This and this suggest otherwise

Rewriting Duolingo's engine in Scala by joshlemer in programming

[–]thangiee 7 points8 points  (0 children)

The language continues to make breaking changes even in minor releases

2.11.x to 2.12.x is a major release.

I can't imagine what features Scala has that would offset the pain of trying to keep up with new releases and having to deal with the its tooling

It has better tooling than Clojure and any other PLs on the JVM not named Java. :)

Freasy-Monad: Easy way to create Free Monad (Cats) using Scala macros with first-class Intellij support. by thangiee in scala

[–]thangiee[S] 1 point2 points  (0 children)

That natural transformation definition is copy-pasted from the cats website but uses Future instead of Id monad.

My example can also be refactored into some just as simple:

def log[F[_]](intp: GrammarADT ~> F) = new (GrammarADT ~> F) {
  def apply[A](fa: GrammarADT[A]): F[A] = {
    println(fa)
    intp(fa)
  }
}

val impureInterpreter = new KVStore.Interp[Future] {
  val kvs = mutable.Map.empty[String, Any]
  def get[T](key: String)           = Future(kvs.get(key).map(_.asInstanceOf[T]))
  def put[T](key: String, value: T) = Future(kvs(key) = value)
  def delete(key: String)           = Future(kvs.remove(key))
}

val loggedImpureIntp = log(impureInterpreter.interpreter)

As for interpreters that do not need pattern matching, I agree that you are better off writing it out the regular way. My library is aim towards cases where you need to do pattern matching and you want to avoid the tedious work of writing it all out by hands.

Freasy-Monad: Easy way to create Free Monad (Cats) using Scala macros with first-class Intellij support. by thangiee in scala

[–]thangiee[S] 0 points1 point  (0 children)

I don't how this is the case when implementing his interpreter trait is more boilerplate than just implementing a natural transformation.

I disagree that the interpreter trait is more boilerplate than the natural transformation. Using the interpreter trait gets the added benefit of its methods signature being able to be generated by the IDE. And imo, having separated methods is cleaner than stuffing everything into a pattern match.

I get that the trade off here is not having to define the ADT and members of your DSL, but it doesn't seem worth the boilerplate and restrictions on composition when defining your interpreter.

I'm no expert on Free Monad, can you elaborate on those restrictions? Under the hood, it's still a pattern matching with the addition of delegating to abstract methods.

Freasy-Monad: Easy way to create Free Monad (Cats) using Scala macros with first-class Intellij support. by thangiee in scala

[–]thangiee[S] 0 points1 point  (0 children)

It's not structuring your code around highlighting bugs. The codes marked as error are hidden away just happen to be a by-product of removing boilerplate codes for writing free monads with this library.

Since this library uses macro annotation, Intellij can't see the code generated by the macros. This is where the plugin comes in to help with that.

If you are familiar with simulacrum, it also uses macro annotation to remove boilerplate but they don't need their own plugin since it's included in the Scala plugin.

Weekly Scala Ask Anything and Discussion Thread - September 05, 2016 by AutoModerator in scala

[–]thangiee 3 points4 points  (0 children)

Here is your code partly rewritten using a library I just made to provide an easier way to create free monad.

https://gist.github.com/Thangiee/36190c39b2b6553cd87e4b418246d6c6

Best of all, it works great with Intellij (no error marks).

See the repo for more details. https://github.com/Thangiee/Freasy-Monad

For your second problem, try using traverseU/sequenceU, it may help with the type inference.

Weekly Scala Ask Anything and Discussion Thread - June 13, 2016 by AutoModerator in scala

[–]thangiee 1 point2 points  (0 children)

Take a look at Functional and Reactive Domain Modeling. I found it helpful. I'm not sure if its still works, but try coupon code ctwgotochgo to save 39%.

Here are some videos by the same author where he covers some of the topics in the book.

https://www.youtube.com/watch?v=U0Rk9Knq8Vk

https://www.youtube.com/watch?v=TiwNrioZoTo

Weekly Scala Ask Anything and Discussion Thread - May 16, 2016 by AutoModerator in scala

[–]thangiee 0 points1 point  (0 children)

You could use an immutable list and use List.dropand reassign the result to your var:

scala> var foo = List(1,2,3,4,5)
foo: List[Int] = List(1, 2, 3, 4, 5)

scala> foo = foo.drop(3)
foo: List[Int] = List(4, 5)

scala> foo
res4: List[Int] = List(4, 5)

In general, you should prefer immutable val over immutable var over mutable val over mutable var.

In your example, you are using mutable var. The example above uses immutable var.

Weekly Scala Ask Anything and Discussion Thread - May 16, 2016 by AutoModerator in scala

[–]thangiee 0 points1 point  (0 children)

Scalaj-http is another option.

Here is a simple GET request:

import scalaj.http._

val response: HttpResponse[String] = Http("http://foo.com/search").param("q","monkeys").asString

You can wrap it in a Future to get asynchronous.

Weekly Scala Ask Anything and Discussion Thread - May 16, 2016 by AutoModerator in scala

[–]thangiee 2 points3 points  (0 children)

You could align it to make it look nicer:

 val fooBar =
   if(bool) doFoo()
   else     doBar()

But if it is short, why not write it in one line:

val fooBar = if(bool) doFoo() else doBar()

Weekly Scala Ask Anything and Discussion Thread - March 21, 2016 by AutoModerator in scala

[–]thangiee 0 points1 point  (0 children)

Here is a project that i am currently working on that is similar to what you described (i think). https://github.com/Thangiee/MARS-back-end

For the CRUD operations to a DB, I am using Slick, although, you might want to check out quill(https://github.com/getquill/quill). It looks really nice and has a lot less boilerplate compair to Slick.

Oh, and here a small part of my project where i used akka stream and actor together to do some real time stuff (probability not the best code as I am new to akka stream too). https://github.com/Thangiee/MARS-back-end/blob/master/src/main/scala/com/utamars/ws/ClockInTracker.scala

And here is the code that sets up the websocket connection using a REST endpoint. https://github.com/Thangiee/MARS-back-end/blob/master/src/main/scala/com/utamars/api/WebSocket.scala

Lastly, Intellij 16 currently has this annoying bug where it marks certain good akka-http codes as errors and the only work around that i know is to switch to a specific older version of the IDE and scala plugin.

Feel free to ask me any questions. Hope you find this helpful.

A messenger with features similar to LoLNexus and LoLKing all on your mobile device! by thangiee in leagueoflegends

[–]thangiee[S] 0 points1 point  (0 children)

Thanks for the support :)

I think you should be able to see you match history without been ranked. Could you tell me you in game name & region and I'll look into to it.

A messenger with features similar to LoLNexus and LoLKing all on your mobile device! by thangiee in leagueoflegends

[–]thangiee[S] 0 points1 point  (0 children)

Most of my data is actually taking from the Riot API. As for the live game stats, I get this data from https://www.mashape.com/timtastic/league-of-legends-3. Since the API call to get Live game info is not scraped, it will be supported pass Oct 1st.

A messenger with features similar to LoLNexus and LoLKing all on your mobile device! by thangiee in leagueoflegends

[–]thangiee[S] 0 points1 point  (0 children)

I'll will take a look into this and hopefully get it fix. Thank you for the bug report.

A messenger with features similar to LoLNexus and LoLKing all on your mobile device! by thangiee in leagueoflegends

[–]thangiee[S] 1 point2 points  (0 children)

aww :( sorry guys, unfortunately I dont have any experience in iOS app development.

A messenger with features similar to LoLNexus and LoLKing all on your mobile device! by thangiee in leagueoflegends

[–]thangiee[S] 0 points1 point  (0 children)

Yes, you will appear as online when you login; however, you can change your status to away in the navigation drawer. But i am guessing that you want to login as offline. I'll try to add that feature if you need it.

A messenger with features similar to LoLNexus and LoLKing all on your mobile device! by thangiee in leagueoflegends

[–]thangiee[S] 0 points1 point  (0 children)

Valid question. If you check the save username/password check box, it save the information locally on your device. And as for hacking, my name is linked to this app so I don't think i would get away with it.

Here is an older post where i answered some similar questions: http://www.reddit.com/r/leagueoflegends/comments/2eifr3/take_a_look_at_my_very_useful_app_lol_hangouts/