Тёмный

The Haskell Unfolder Episode 28: type families and overlapping instances 

Well-Typed
Подписаться 1,8 тыс.
Просмотров 591
50% 1

In this episode, we discuss a programming technique which allows us to replace overlapping instances with a decision procedure implemented using type families. The result is a bit more verbose, but arguably clearer and more flexible.

Опубликовано:

 

20 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 5   
@tobzdaman619
@tobzdaman619 2 месяца назад
Didn't understand anything about type families up until today. They're still daunting but this video is very helpful and I'll be following along on the weekend. The boilerplate is a bit painful and you do have to work quite a ways backwards to figure out what's going on: but the power is apparent. Thank you very much! :D
@byteeater7662
@byteeater7662 2 месяца назад
Can there be a variant of Flatten that flattens [[True], [False, True]] to [True, False, True] and Just (Just (Just True)) to Just True (I think it's clear enough from these examples what generalization I've got in mind)?
@edskodevries
@edskodevries 2 месяца назад
Certainly! We demonstrated flattening Maybe to list just as a teaching device; flattening maybes in the manner that you describe would be quite natural. You will need to introduce a second type family IsMaybe alongside IsList. Nice exercise for the reader :)
@byteeater7662
@byteeater7662 2 месяца назад
I've envisioned a universal solution whereby no IsList, IsMaybe (perhaps IsTree and other similar variants too) are needed, just one generalizing all of them (subject to some constraint, likely Functor or Applicative). Maybe quantified constraints make it possible?
@edskodevries
@edskodevries 2 месяца назад
@@byteeater7662 That is a lot trickier to do. You could certainly provide an instance for (m a) , and then insist that (m) must be a monad (so that we can call join :: m (m (a) - > m a), but now you are ruling out any instances of the same shape (f a) -- unless you use overlapping instances again.
Далее
The Haskell Unfolder Episode 30: runST
40:54
How to Build a Homemade Bike Using a Barrel
00:21
Просмотров 1,6 млн
Stream transformers with Paul and Rúnar
1:08:56
The Haskell Unfolder Episode 31: nothunks
37:05
Learning Closed Type Families Together!
13:37
Просмотров 1 тыс.
05-02 The IO Type (Introduction to Haskell)
23:02