juan_gandhi: (Default)
2021-05-28 07:32 am
Entry tags:

tuesday event


John De Goes is Programming Without Type Classes



Type classes have become a cornerstone of statically-typed functional programming, powering abstractions like monoid and monad. Yet, type classes often have generalized names, which don’t reflect their purpose in specific domains; and they incur higher learning costs, especially when emulated in languages without them.

In this presentation, John De Goes discusses the pros and cons of using type classes, and presents a systematic method for building powerful functional components that do not require type classes. Attendees will learn how to preserve the benefits of principled, algebraic functional programming, without forcing type classes on coworkers or users.
juan_gandhi: (Default)
2021-04-12 12:15 pm
Entry tags:

понедельничек

Юджин Йокота деплойнул sbt в jfrog, вместо чего-то там.

В результате по всей планете билды скальных продуктов сломаны.

Вот это заебись надежность. Я вообще не понимаю, как можно бесконтрольные апдейты устраивать.
juan_gandhi: (Default)
2021-04-06 07:05 pm
Entry tags:

regarding Scala types

Had a discussion yesterday. Basically, about this equality:

scala> "abc": Iterable[Char]
val res0: Iterable[Char] = abc

scala> List('a', 'b', 'c'): Iterable[Char]
val res1: Iterable[Char] = List(a, b, c)

scala> res0 == res1                                                                                                        
val res2: Boolean = true


No surprise, just making sure that it behaves as expected. Two projections are equal.
juan_gandhi: (Default)
2021-03-06 10:57 am
Entry tags:

а вот немножко логики

Вот простые два теста на Котлине.

    Stream.of<String>().forAll {   it.isEmpty() } shouldBe true
Stream.of<String>().forAll { !it.isEmpty() } shouldBe true



Не очень понятно, как это непрофессионалы воспримут. Моим студентам требуются усилия обычно.





juan_gandhi: (Default)
2020-12-24 07:06 am
Entry tags:

munit

 Послушал тут доклад на мадридском митапе, про munit - ну как-то не вижу смысла; junit надоел хуже горькой редьки, а этот не особо далеко ушел, только что stack trace highlighting. Я уж лучше specs2 продолжу использовать.

Или?
juan_gandhi: (Default)
2020-12-19 01:44 pm
Entry tags:

strange scala code

def x: { def k: Int } = new { def k: Int = 42 }

 

juan_gandhi: (Default)
2020-12-08 09:19 am
Entry tags:

just figured

 Just figured, `_` in Scala is an example of anaphora.
juan_gandhi: (Default)
2020-08-01 01:34 pm
Entry tags:

с ужасом обнаружил...

Что в ScalaZ ноль тестов для OptionT. Я им когда-то навалял тест для finger trees, ну и. Короче, за столько лет если не сбацали, так и все уже, наверно. Хм. Это я хотел поэкспериментировать. Потому что не совсем понимаю причин коммутирования (и могу привести простой контрпример). Пошел смотреть, как оно в typelevel/cats. In short. Have to use cats. Probably not. Will take a look at ZIO later.
juan_gandhi: (Default)
2020-06-27 07:48 am
Entry tags:

пара заметок

Ночью приходил енот, помыл кошкину миску. Почему этого енота не записала камера, непонятно.

Regarding type parameters and member types. Say, you have trait T[X]{}. With a certain caveat, you may view it as a functor. If you have trait T { type X }. We have a partial mapping that, given a type, produces X (or not).

We can as well view both as binary relations between types (or profunctors, if we go to categories). One is an inverse of another.

So when you choose which one to prefer, mind the meaning of it.

(inspired by Compall's blog from 2015.
juan_gandhi: (Default)
2020-05-11 10:02 am
Entry tags:

seems like a compiler bug

Welcome to Scala 2.12.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_92).
Type in expressions for evaluation. Or try :help.

scala> def f(x: Int) = 10 + x -> "ok"
f: (x: Int)(Int, String)

scala> f(10)
res0: (Int, String) = (20,ok)

scala> def g(x: Int) = 20 + x → "oops"
:11: error: overloaded method value + with alternatives:
  (x: Double)Double 
  (x: Float)Float 
  (x: Long)Long 
  (x: Int)Int 
  (x: Char)Int 
  (x: Short)Int 
  (x: Byte)Int 
  (x: String)String
 cannot be applied to ((Int, String))
       def g(x: Int) = 20 + x → "oops"
                          ^