[personal profile] sassa_nf
А вот скажите, пожалуйста.

data Console a = Console { runConsole :: ConsoleStruct -> IO a }
data Coords = Coords Int Int
...
cursorCoords :: Console Coords
cursorCoords = Console getCursorCoords

getCursorCoords :: ConsoleStruct -> IO a
getCursorCoords c = someNativeFunction c >>= peek
Так вот, что за cursorCoords? Это функтором перенесённая getCursorCoords? Типа, все объекты и стрелки переносятся generically, а выборочно Console ConsoleStruct = (), и Console getCursorCoords = cursorCoords?

С одной стороны - вроде бы да, а с другой стороны - дык, fmap getCursorCoords в принципе тоже существует. Как же так?


Нет, не так. Поскольку CCC, то getCursorCoords соответствует curried функция ()→IO Coords, т.е. (IO Coords)ConsoleStruct. Этот объект, как и все, отображается функтором, т.е. попадаем в Console Coords. А cursorCoords - просто именованная ссылка на именно этот объект. Вот.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

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 03:13 am
Powered by Dreamwidth Studios