I hereby claim:
- I am dmwit on github.
- I am dmwit (https://keybase.io/dmwit) on keybase.
- I have a public key whose fingerprint is FBCF E1CE 584E 46E2 CEC5 692A 620F C421 171F 63FF
To claim this, I am signing this object:
| module Custom ( | |
| showEven, | |
| showBoolean | |
| ) where | |
| showEven:: Int-> Bool | |
| showEven x = x `rem` 2 == 0 | |
| showBoolean :: Bool->Int | |
| showBoolean c = if c then 1 else 0 |
| > mapM_ (print . pretty) $ runInfer (SourceApp (SourceApp (SourceVar "plus") (SourceVar "readLn")) (SourceVar "readLn")) | |
| let appPMPPM f x = pure (f (pure x)) | |
| appMaMaM f x = f >>= ($x) | |
| appMMMPM f x = f >>= ($pure x) | |
| appMPMMM f x = f >>= (x>>=) | |
| appMaPaM f x = fmap ($x) f | |
| appMMPPM f x = fmap ($pure x) f | |
| in | |
| (<*>) (fmap plus readLn) readLn | |
| :: m _ |
| % tree | |
| . | |
| ├── a | |
| │ └── a.cabal | |
| └── b | |
| ├── b.cabal | |
| └── cabal.project.local | |
| 2 directories, 3 files | |
| % cat a/a.cabal |
| -- Test.hs | |
| {-# LANGUAGE PatternSynonyms #-} | |
| module Test (Foo(Bar,Baz)) where | |
| data Foo = Bar | |
| pattern Baz = Bar | |
| -- whatever-else.hs | |
| import Test (Foo(Baz)) |
| sums :: Num a => [a] -> (a, [a]) | |
| sums [] = (0, []) | |
| sums (x:xs) = let ~(v,vs) = sums xs; v' = v+x in v' `seq` (v',v':vs) | |
| main :: IO () | |
| main = print (fst (sums [0..1000000 :: Int])) | |
| -- OR | |
| -- main = print (last (scanl1 (+) [0..1000000 :: Int])) |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| import Type.Reflection | |
| data Foo = Int Int | Bool Bool | |
| wrap :: Typeable b => b -> Maybe Foo | |
| wrap b | |
| | Just HRefl <- eqTypeRep t (typeRep @Int) = Just (Int b) | |
| | Just HRefl <- eqTypeRep t (typeRep @Bool) = Just (Bool b) |
| In the Essence of Automatic Differentiation, Conal defines | |
| D+ :: (a -> b) -> a -> (b, a -o b) | |
| D+(f,a) = (f(a), D(f,a)) | |
| where a and b are vector spaces, -o is the space of linear functions, and D is | |
| the derivative operation. | |
| But to me this suffers the same problem as considering numbers to be the | |
| derivatives of 1D spaces functions, vectors/matrices for higher dimensions, |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| import Control.Monad.Reader (ReaderT) | |
| import Control.Monad.State (StateT) | |
| import qualified Control.Monad.Reader as R | |
| import qualified Control.Monad.State as S | |
| class Monad m => DmwitMonadReader m where | |
| type Env m | |
| type Wrapped m :: * -> * |
| import Data.Map (Map) | |
| import qualified Data.Map as M | |
| partitionM :: Applicative f => (a -> f Bool) -> [a] -> f ([a], [a]) | |
| partitionM f xs = mconcat <$> traverse inject xs where | |
| inject x = (\b -> ([x | b], [x | not b])) <$> f x | |
| partitions :: Ord a => [a] -> [Map a Integer] | |
| partitions = go 0 where | |
| go _ [] = [M.empty] |
I hereby claim:
To claim this, I am signing this object: