I hereby claim:
- I am rufflewind on github.
- I am rufflewind (https://keybase.io/rufflewind) on keybase.
- I have a public key whose fingerprint is 760E 9C79 FB40 607A 1F52 AE49 0346 7153 8EB1 6548
To claim this, I am signing this object:
| -- Exercise: prove Peirce’s law <=> law of excluded middle in Haskell | |
| {-# LANGUAGE Rank2Types #-} | |
| module PeirceLEM where | |
| import Data.Void | |
| type Not a = a -> Void | |
| type Peirce = forall a b. ((a -> b) -> a) -> a |
| 0 | |
| o\ | |
| =0\ | |
| -+-0 | |
| d=''' | |
| KAkAAA | |
| BzCwAAA | |
| E1BU1RFU | |
| k1JTkQKcx | |
| EAAABFbnRl |
I hereby claim:
To claim this, I am signing this object:
Type classes are rather fragile: it's really hard to make changes to a type class once because it can often break code downstream.
Type classes are in a sense like implicit parameters, with the additional constraint of coherency. If we think of them as such, then defining an instance such as
instance Monad Maybe where
(>>=) = …| import qualified Data.ByteString as B | |
| import qualified Data.ByteString.Char8 as C | |
| data Vec a = Vec { vecx, vecy, vecz :: !a } | |
| instance Functor Vec where | |
| fmap f (Vec x y z) = Vec (f x) (f y) (f z) | |
| instance Applicative Vec where | |
| pure x = Vec x x x |
| TIMEUNIT_MICROSECOND = 0 | |
| TIMEUNIT_SECOND = 1 | |
| TIMEUNIT_MINUTE = 2 | |
| TIMEUNIT_HOUR = 3 | |
| TIMEUNIT_DAY = 4 | |
| TIMEUNIT_MONTH = 5 | |
| TIMEUNIT_YEAR = 6 | |
| def round_datetime(timeunit): | |
| '''Round the given time downward to some unit of time. For example: |
| // stat.c | |
| // | |
| // TO RUN: cc -Wall stat.c && ./a.out | |
| #include <fcntl.h> | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <sys/stat.h> | |
| #include <sys/types.h> |