[personal profile] sassa_nf
Тю, я думал, это в скале проблема, что нужно вручную прописывать, где мне нужно ApList.<*>, а где ZapList.<*>. А в Хаскеле вообще, стало быть, нельзя сослаться на разные реализации в одном модуле? Или как ещё late binding решается? (кроме, конечно, вручную написанного virtual method table словаря, как здесь: http://www.joachim-breitner.de/blog/archives/398-Making-dictionary-passing-explicit-in-Haskell.html)

Date: 2012-12-19 02:41 pm (UTC)
From: [identity profile] palm-mute.livejournal.com
Еще можно в newtype завернуть, по ссылке этот вариант упоминается.

Date: 2012-12-19 03:01 pm (UTC)
From: [identity profile] sassa-nf.livejournal.com
да, спасибо, я потом Sum и Product посмотрел - яснее стало.

Date: 2012-12-19 06:10 pm (UTC)
From: [identity profile] juan-gandhi.livejournal.com
These are two distinct functors, and theorems for free do not provede the answer.

Date: 2012-12-19 09:16 pm (UTC)
From: [identity profile] sassa-nf.livejournal.com
Yes, these are two distinct functors.

I was only wondering how "smoothly" haskell code looked in McBride-Patterson (no fully-qualified name needed - everything used just plain <$>), but I think it is deceptive. If we wanted to mix both ApList and ZapList in the same module in haskell, there'd be a problem similar to what I tried to solve in Scala Kittens (try to create some scope, where <*> is treated as one of them, and if you wanted another one, use qualified name).

In this respect it is a problem similar to choosing a Monoid (Sum and Product exist - but which one do you need here, if you just write "mappend").

Date: 2012-12-20 04:47 am (UTC)
From: [identity profile] juan-gandhi.livejournal.com
Right; but it's an interesting challenge.

Date: 2012-12-20 05:07 pm (UTC)
From: [identity profile] palm-mute.livejournal.com
В Скале вроде бы задача проще решается, ведь implicits можно импортировать в любой scope.

Date: 2012-12-20 06:34 pm (UTC)
From: [identity profile] sassa-nf.livejournal.com
ну Иван Джавахарлалович как-то так и сделал. Мне не очень понравилось то, что мы задаём тип аргумента, а уж потом на нём можем вызвать <*>. Получилось похоже на хаскельный вариант решения такой проблемы, между прочим, за вычетом каких-то нюансов, я забыл уже.

Я пытался выразить эту идею по-другому, т.е. вид <*> выбирать в месте, где "вызывается" <*>.

Profile

sassa_nf

February 2026

S M T W T F S
1234567
891011121314
15161718192021
222324252627 28

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 22nd, 2026 02:24 am
Powered by Dreamwidth Studios