Sergey
В 3
Ayrat
Это тайп классы?
На них их можно сделать
Ayrat
а можно ноги отстрелить
Ayrat
вон в хаскеле есть тайп классы, а нет имплиситов
Doge
Но чуть другие
Ayrat
ну они тоже стремно импортируются, это да
Doge
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#implicit-parameters
Ayrat
это опшун
Ayrat
по умолчанию он не включен я подозреваю
Doge
это опшун
В хаскеле ничего из реально используемого не включено по умолчанию
Doge
Все в реальных кодовых базах ходят с кучей экстенсинов
Doge
А потом у каждого свой хаскел
Нет, там набор практически одинаковый у всех
Doge
Т.е. без тех же OverloadedStrings не написать не один реальный проект
Roman
это что такое?
Doge
Потому что дефолтные строки - очень своеобразная хрень в хаскеле
Doge
это что такое?
Возомжность, чтобы строковые литеры автоматом конвертились в твой тип строк
Doge
Пахнет плюсами
Ну скорее строки представленные связными, ленивыми списками - это плохой дефолт
Doge
И почему их по-умолчанию нет?
Исторические причины, изначально не подумали, а потом уже зачем включать то, что есть в либах. Т.к. в каких-то кейсах тебе реально хочется ленивые строки, которые списки-итераторы. Где-то хочется строку как ленивый/неленивый набор байт (bytestring), где-то хочется как ленивый/неленивый набор Unicode символов (text)
Ayrat
И почему их по-умолчанию нет?
Там еще сто видов чисел
Ayrat
Int Nat Integer Natural Integral
Ayrat
сиде ебись
Doge
Там еще сто видов чисел
Скорее встроенная числовая иерархия тайпклассов вообще никакая. В пурсе лучше
Doge
Но это тоже исторические причины
Doge
На них их можно сделать
Ну и да, проще сказать чего на них нельзя сделать. Т.к. на них делают зависимые функции, тайп левел вычисления, экстенжион методы (см. implicit class), аналоги котлиновских receiver функций (см. implicit function types) и т.д. и т.п.
Ayrat
Короче, тайпклассы хорошо. Все остальное - фуфуфу. Всю эту ссанину с импортом неявным непойми чего непойми откуда надо выжигать и запретить импорт имплиситов через import package._
Ayrat
ну и мокать имплиситы тоже интересное удовольствие.
Doge
Отдельные
Vasily
Вообще,call by name штука неплохая, но в увлекающихся руках опасная
Vasily
По факту, в скале же не значения передаются, а некие ссылки, как я понимаю
Vasily
Поэтому скалисты любят щеголять словом материализация
Vasily
И переписывать графы выполнения
Vasily
call by name такое сильно облегчает
Shub
тут вчера писали, мол если команда понимает, то тогда и дырки в типах - только во благо
Shub
а если команда еще и делает - то можно сразу умирать, потому что это кульминация вашей жизни
Shub
минвайл, ваша команда:
Shub
[<SuppressMessage("*", "TypeNames")>] type posint = private Posint of int with static member OfInt = Constrain.constrain (fun (n : int) -> if n > 0 then Success (Posint n) else failf "Expected positive int, received %d" n) member this.Value = let (Posint v) = this in v // posint & int static member (+) (Posint p1, p2 : int) = p1 + p2 static member (+) (p1 : int, Posint p2) = p1 + p2 static member (*) (Posint p1, p2 : int) = p1 * p2 static member (*) (p1 : int, Posint p2) = p1 * p2 static member (-) (Posint p1, p2 : int) = p1 - p2 static member (-) (p1 : int, Posint p2) = p1 - p2 static member (/) (Posint p1, p2 : int) = p1 / p2 static member (/) (p1 : int, Posint p2) = p1 / p2 // posint & posint static member (+) (Posint p1, Posint p2) = Posint (p1 + p2) static member (-) (Posint p1, Posint p2) = p1 - p2 static member (*) (Posint p1, Posint p2) = Posint (p1 * p2) static member (/) (Posint p1, Posint p2) = Posintz (p1 / p2) // posint & posintz static member (+) (Posint p1, Posintz p2) = Posint (p1 + p2) static member (-) (Posint p1, Posintz p2) = p1 - p2 static member (*) (Posint p1, Posintz p2) = Posintz (p1 * p2) static member (/) (Posint p1, Posintz p2) = Posintz (p1 / p2) // posint & negint static member (+) (Posint p1, Negint p2) = p1 + p2 static member (-) (Posint p1, Negint p2) = Posint (p1 - p2) static member (*) (Posint p1, Negint p2) = Negint (p1 * p2) static member (/) (Posint p1, Negint p2) = Negintz (p1 / p2) // posint & negintz static member (+) (Posint p1, Negintz p2) = p1 + p2 static member (-) (Posint p1, Negintz p2) = Posint (p1 - p2) static member (*) (Posint p1, Negintz p2) = Negintz (p1 * p2) static member (/) (Posint p1, Negintz p2) = Negintz (p1 / p2) and [<SuppressMessage("*", "TypeNames")>] posintz = private Posintz of int with static member OfInt = Constrain.constrain (fun (n : int) -> if n >= 0 then Success (Posintz n) else failf "Expected non-negative int, received %d" n) member this.Value = let (Posintz v) = this in v // posintz & int static member (+) (Posintz p1, p2 : int) = p1 + p2 static member (+) (p1 : int, Posintz p2) = p1 + p2 static member (*) (Posintz p1, p2 : int) = p1 * p2 static member (*) (p1 : int, Posintz p2) = p1 * p2 static member (-) (Posintz p1, p2 : int) = p1 - p2 static member (-) (p1 : int, Posintz p2) = p1 - p2 static member (/) (Posintz p1, p2 : int) = p1 / p2 static member (/) (p1 : int, Posintz p2) = p1 / p2 // posintz & posintz static member (+) (Posintz p1, Posintz p2) = Posintz (p1 + p2) static member (-) (Posintz p1, Posintz p2) = p1 - p2 static member (*) (Posintz p1, Posintz p2) = Posintz (p1 * p2) static member (/) (Posintz p1, Posintz p2) = Posintz (p1 / p2) // posintz & posint static member (+) (Posintz p1, Posint p2) = Posint (p1 + p2) static member (-) (Posintz p1, Posint p2) = p1 - p2 static member (*) (Posintz p1, Posint p2) = Posintz (p1 * p2) static member (/) (Posintz p1, Posint p2) = Posintz (p1 / p2) // posintz & negint static member (+) (Posintz p1, Negint p2) = p1 + p2 static member (-) (Posintz p1, Negint p2) = Posint (p1 - p2) static member (*) (Posintz p1, Negint p2) = Negintz (p1 * p2) static member (/) (Posintz p1, Negint p2) = Negintz (p1 / p2)
Shub
// posintz & negintz static member (+) (Posintz p1, Negintz p2) = p1 + p2 static member (-) (Posintz p1, Negintz p2) = Posintz (p1 - p2) static member (*) (Posintz p1, Negintz p2) = Negintz (p1 * p2) static member (/) (Posintz p1, Negintz p2) = Negintz (p1 / p2) and [<SuppressMessage("*", "TypeNames")>] negint = private Negint of int with static member OfInt = Constrain.constrain (fun (n : int) -> if n < 0 then Success (Negint n) else failf "Expected negative int, received %d" n) // negint & int static member (+) (Negint p1, p2 : int) = p1 + p2 static member (+) (p1 : int, Negint p2) = p1 + p2 static member (*) (Negint p1, p2 : int) = p1 * p2 static member (*) (p1 : int, Negint p2) = p1 * p2 static member (-) (Negint p1, p2 : int) = p1 - p2 static member (-) (p1 : int, Negint p2) = p1 - p2 static member (/) (Negint p1, p2 : int) = p1 / p2 static member (/) (p1 : int, Negint p2) = p1 / p2 // negint & negint static member (+) (Negint p1, Negint p2) = Negint (p1 + p2) static member (-) (Negint p1, Negint p2) = p1 - p2 static member (*) (Negint p1, Negint p2) = Posint (p1 * p2) static member (/) (Negint p1, Negint p2) = Posintz (p1 / p2) // negint & posint static member (+) (Negint p1, Posint p2) = p1 + p2 static member (-) (Negint p1, Posint p2) = Negint (p1 - p2) static member (*) (Negint p1, Posint p2) = Negint (p1 * p2) static member (/) (Negint p1, Posint p2) = Negintz (p1 / p2) // negint & posintz static member (+) (Negint p1, Posintz p2) = p1 + p2 static member (-) (Negint p1, Posintz p2) = Negint (p1 - p2) static member (*) (Negint p1, Posintz p2) = Negintz (p1 * p2) static member (/) (Negint p1, Posintz p2) = Negintz (p1 / p2) // negint & negintz static member (+) (Negint p1, Negintz p2) = Negint (p1 + p2) static member (-) (Negint p1, Negintz p2) = p1 - p2 static member (*) (Negint p1, Negintz p2) = Posintz (p1 * p2) static member (/) (Negint p1, Negintz p2) = Posintz (p1 / p2) and [<SuppressMessage("*", "TypeNames")>] negintz = private Negintz of int with static member OfInt = Constrain.constrain (fun (n : int) -> if n <= 0 then Success (Negintz n) else failf "Expected non-positive int, received %d" n) // negintz & int static member (+) (Negintz p1, p2 : int) = p1 + p2 static member (+) (p1 : int, Negintz p2) = p1 + p2 static member (*) (Negintz p1, p2 : int) = p1 * p2 static member (*) (p1 : int, Negintz p2) = p1 * p2 static member (-) (Negintz p1, p2 : int) = p1 - p2 static member (-) (p1 : int, Negintz p2) = p1 - p2 static member (/) (Negintz p1, p2 : int) = p1 / p2 static member (/) (p1 : int, Negintz p2) = p1 / p2 // negintz & negintz static member (+) (Negintz p1, Negintz p2) = Negintz (p1 + p2) static member (-) (Negintz p1, Negintz p2) = p1 - p2 static member (*) (Negintz p1, Negintz p2) = Posintz (p1 * p2) static member (/) (Negintz p1, Negintz p2) = Posintz (p1 / p2) // negintz & posint static member (+) (Negintz p1, Posint p2) = p1 + p2 static member (-) (Negintz p1, Posint p2) = Negint (p1 - p2) static member (*) (Negintz p1, Posint p2) = Negintz (p1 * p2) static member (/) (Negintz p1, Posint p2) = Negintz (p1 / p2) // negintz & posintz static member (+) (Negintz p1, Posintz p2) = p1 + p2 static member (-) (Negintz p1, Posintz p2) = Negintz (p1 - p2) static member (*) (Negintz p1, Posintz p2) = Negintz (p1 * p2) static member (/) (Negintz p1, Posintz p2) = Negintz (p1 / p2)
Shub
// negintz & negint static member (+) (Negintz p1, Negint p2) = Negint (p1 + p2) static member (-) (Negintz p1, Negint p2) = p1 - p2 static member (*) (Negintz p1, Negint p2) = Posintz (p1 * p2) static member (/) (Negintz p1, Negint p2) = Posintz (p1 / p2) let posintf = posint.OfInt.Create let posint = posint.OfInt.TryCreate let posintzf = posintz.OfInt.Create let posintz = posintz.OfInt.TryCreate let negintf = negint.OfInt.Create let negint = negint.OfInt.TryCreate let negintzf = negintz.OfInt.Create let negintz = negintz.OfInt.TryCreate
Λ ll И K X
есть же pastebin
Λ ll И K X
зачем
Λ ll И K X
Shub
у меня нету
Λ ll И K X
pastebin.com
Shub
The IP/Domain has been blocked due to a known security risk.
Λ ll И K X
держи
Shub
спасибо
Doge
минвайл, ваша команда:
А что значит z на конце второго Posint?
Doge
Может быть 0
Да, видимо
Ayrat
[<SuppressMessage("*", "TypeNames")>] type posint = private Posint of int with static member OfInt = Constrain.constrain (fun (n : int) -> if n > 0 then Success (Posint n) else failf "Expected positive int, received %d" n) member this.Value = let (Posint v) = this in v // posint & int static member (+) (Posint p1, p2 : int) = p1 + p2 static member (+) (p1 : int, Posint p2) = p1 + p2 static member (*) (Posint p1, p2 : int) = p1 * p2 static member (*) (p1 : int, Posint p2) = p1 * p2 static member (-) (Posint p1, p2 : int) = p1 - p2 static member (-) (p1 : int, Posint p2) = p1 - p2 static member (/) (Posint p1, p2 : int) = p1 / p2 static member (/) (p1 : int, Posint p2) = p1 / p2 // posint & posint static member (+) (Posint p1, Posint p2) = Posint (p1 + p2) static member (-) (Posint p1, Posint p2) = p1 - p2 static member (*) (Posint p1, Posint p2) = Posint (p1 * p2) static member (/) (Posint p1, Posint p2) = Posintz (p1 / p2) // posint & posintz static member (+) (Posint p1, Posintz p2) = Posint (p1 + p2) static member (-) (Posint p1, Posintz p2) = p1 - p2 static member (*) (Posint p1, Posintz p2) = Posintz (p1 * p2) static member (/) (Posint p1, Posintz p2) = Posintz (p1 / p2) // posint & negint static member (+) (Posint p1, Negint p2) = p1 + p2 static member (-) (Posint p1, Negint p2) = Posint (p1 - p2) static member (*) (Posint p1, Negint p2) = Negint (p1 * p2) static member (/) (Posint p1, Negint p2) = Negintz (p1 / p2) // posint & negintz static member (+) (Posint p1, Negintz p2) = p1 + p2 static member (-) (Posint p1, Negintz p2) = Posint (p1 - p2) static member (*) (Posint p1, Negintz p2) = Negintz (p1 * p2) static member (/) (Posint p1, Negintz p2) = Negintz (p1 / p2) and [<SuppressMessage("*", "TypeNames")>] posintz = private Posintz of int with static member OfInt = Constrain.constrain (fun (n : int) -> if n >= 0 then Success (Posintz n) else failf "Expected non-negative int, received %d" n) member this.Value = let (Posintz v) = this in v // posintz & int static member (+) (Posintz p1, p2 : int) = p1 + p2 static member (+) (p1 : int, Posintz p2) = p1 + p2 static member (*) (Posintz p1, p2 : int) = p1 * p2 static member (*) (p1 : int, Posintz p2) = p1 * p2 static member (-) (Posintz p1, p2 : int) = p1 - p2 static member (-) (p1 : int, Posintz p2) = p1 - p2 static member (/) (Posintz p1, p2 : int) = p1 / p2 static member (/) (p1 : int, Posintz p2) = p1 / p2 // posintz & posintz static member (+) (Posintz p1, Posintz p2) = Posintz (p1 + p2) static member (-) (Posintz p1, Posintz p2) = p1 - p2 static member (*) (Posintz p1, Posintz p2) = Posintz (p1 * p2) static member (/) (Posintz p1, Posintz p2) = Posintz (p1 / p2) // posintz & posint static member (+) (Posintz p1, Posint p2) = Posint (p1 + p2) static member (-) (Posintz p1, Posint p2) = p1 - p2 static member (*) (Posintz p1, Posint p2) = Posintz (p1 * p2) static member (/) (Posintz p1, Posint p2) = Posintz (p1 / p2) // posintz & negint static member (+) (Posintz p1, Negint p2) = p1 + p2 static member (-) (Posintz p1, Negint p2) = Posint (p1 - p2) static member (*) (Posintz p1, Negint p2) = Negintz (p1 * p2) static member (/) (Posintz p1, Negint p2) = Negintz (p1 / p2)
Штоблять.
Doge
Жуть какая-то. Но зачем?
Ilya
А где там дырки?
Vasily
Когда у тайп астронавтов начинается кислородное голодание, умирающий мозг рисует картины посмертных видений
Ayrat
Vasily
В головах там желе
Ilya
А почему нет проверок при сложении Negint и обычного int?
Vasily
Как у разумных амеб из романа Спектр Лукьяненко
Shub
А почему нет проверок при сложении Negint и обычного int?
а какая разница, код-то все равно мертвый
Ilya
Я пытаюсь найти логику.
Shub
логика такая: а ВДРУГ нам в БУДУЩЕМ потребуется неотрицательное целое, ВОТ ЧТО ТЫ БУДЕШЬ ТОГДА ДЕЛАТЬ, А?
Shub
ну впрочем вы еще equinox не видели, в котором на три строчки 5 самописных либ
Ilya
Хм, uint?
Ilya
Хотя если понадобятся только неотрицательные чётные, то будут проблемы.
Ilya
Кажется, тут нужна фабрика.
Shub
Не понял тебя сегодня.
equinox например не может распарсить json без логгинга. и не может подключиться к кафке без FsKafka
Ayrat
Там есть фшарп кодек либа для интеропа разных сериализаторов
Shub
это так только кажется. на самом деле там один - Newtonsoft
Ayrat
Ты там можешь реализовать ICodec или как оно там и подключить
Shub
а мне-то что от этого? по сути, я не могу влиять на формат сериализации, и теперь должен писать FromDto\ToDto, как полный олигофрен, вместо использования нормального враппера