Parametricity
@parametricity
Theorems for Free!
You might like
I wonder what this function does. flip :: Functor f => f (a -> b) -> a -> f b Wait, no I don't.
f :: Lens a b -> a -> b -> a This does one of two things. ∀ l x y. x /= y => f l x y x /= x Now I know which.
@rightfold is thinking of a function with the type (a -> b) -> a -> b The identity function specialized to functions.
length :: Foldable f => f a -> Int ∴ length (1, '2', "3") must return 1.
Generalize an abstraction because removing nonessential information clarifies its independent meaning. Re-use is accidental. @fronx
a -> (a, a, a, a) I definitely know what this function does. (a, a, a, a) -> a I almost know what this function does.
f :: Monad f=>f T -> f T The result might depend on previous effect values g :: Applicative f=>f T -> f T This definitely doesn't though
Proof `fmap f.fmap g=fmap(f.g)` follows from `fmap id=id` and the free theorem: fpcomplete.com/user/edwardk/s… /cc @BartoszMilewski @parametricity
Using Data.Foldable and parametricity, one can be sure that: foldMap f &&& foldMap g = foldMap (f &&& g)
f :: [a] -> [a] This type tells us some, but not all, things. ∀ x. f [x] = [x] ∀ x y. f (x++y) = f y++f x These tests tell us the rest.
f :: a -> a -> a This function does one of two things. test = f 1 2 == 1 Now it is disambiguated between those two.
Reminder. Fast & Loose Reasoning is Morally Correct.
A csharp<A>(A a) This function returns its argument.
(~.~<.~>\\+.) :: (Profunctor p, Functor f) => (a -> f b) -> p b r -> f (p a r) This operator clearly specifies what it does in the type.
Monad f => f a -> f b -> f b Any (a) values from the effect (f a) are not used.
Correction. Applicative f => f a -> f a This function is implemented with only id, (<*) or (*>). Thanks @dino_joel
Applicative => f a -> f a This function is implemented with only id, (<*) or (*>).
IO Int -> a -> Int This function ignores both arguments.
String -> a -> a This function returns the second argument, ignoring the first.
United States Trends
- 1. Marshawn Kneeland 44K posts
- 2. Nancy Pelosi 64.6K posts
- 3. Craig Stammen 1,772 posts
- 4. Gordon Findlay 2,259 posts
- 5. Ozempic 5,780 posts
- 6. Michael Jackson 68.5K posts
- 7. Pujols N/A
- 8. #ThankYouNancy 1,478 posts
- 9. Novo Nordisk 5,971 posts
- 10. GLP-1 4,670 posts
- 11. Abraham Accords 4,279 posts
- 12. #NO1ShinesLikeHongjoong 37.4K posts
- 13. Kazakhstan 6,019 posts
- 14. Kyrou N/A
- 15. #영원한_넘버원캡틴쭝_생일 36.6K posts
- 16. Preller N/A
- 17. Gremlins 3 4,898 posts
- 18. Kinley N/A
- 19. Unplanned 9,115 posts
- 20. Joe Dante N/A
You might like
-
Edward Kmett
@kmett -
Well-Typed
@welltyped -
gabby
@GabriellaG439 -
ICFP Conference
@icfp_conference -
Andres Löh
@kosmikus -
Neil Mitchell (neildmitchell @🪡)
@ndm_haskell -
Michael Snoyman
@snoyberg -
Rúnar
@runarorama -
Alejandro Serrano
@trupill -
Tikhon Jelvis
@tikhonjelvis -
Nikita Volkov
@NikitaYVolkov -
Debasish (দেবাশিস্) Ghosh 🇮🇳
@debasishg -
Jeremy Gibbons
@jer_gib -
Steven Shaw
@steshaw
Something went wrong.
Something went wrong.