Skip to content

Instantly share code, notes, and snippets.

View calebh's full-sized avatar

Caleb Helbling calebh

View GitHub Profile
class Mappable f where
map :: (a -> b) -> f a -> f b
typeclass Mappable<f> {
f<b> map(Func<a, b>, f<a>);
}
class Monad m where
(>>=) :: m a -> ( a -> m b) -> m b
(>>) :: m a -> m b -> m b
x >> y = x >>= \_ -> y
return :: a -> m a
typeclass Monad<m> {
m<b> >>= <a, b>(m<a>, Func<a, m<b>>);
m<b> >> <a, b>(m<a> x, m<b> y) {
return >>= <a, b>(x, (ignored) => y);
}
m<a> return_ <a>(a);
}
instance Monad Maybe where
Nothing >>= f = Nothing
(Just x) >>= f = f x
return = Just
instance Monad [] where
xs >>= f = concat (map f xs)
return x = [x]
typeclassinstance Monad<Nullable> {
Nullable<b> >>= <a,b>(Nullable<a> x, Func<a, Nullable<b>> f) {
if (x.HasValue) {
return f(x.Value);
} else {
return null;
}
}
Nullable<a> return_ <a>(x) {
do
x1 <- expr1
x2 <- expr2
expr3
expr1 >>= (\x1 -> (expr2 >>= (\x2 -> expr3)))
do
expr1
expr2
expr1 >> expr2
@calebh
calebh / hie.log
Created January 27, 2020 06:56
HIE Error
$ hie.exe
2020-01-27 00:43:25.619924 [ThreadId 3] - Cabal-Helper decided to use: ProjLocStackYaml {plStackYaml = "C:\\Users\\caleb\\Documents\\deepdecompilerproject\\dd-c-preprocessor\\stack.yaml"}
stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
2020-01-27 00:43:27.9500122 [ThreadId 3] - Module "C:\Users\caleb\Documents\deepdecompilerproject\dd-c-preprocessor\File.hs" is loaded by Cradle: Cradle {cradleRootDir = "C:\\Users\\caleb\\Documents\\deepdecompilerproject\\dd-c-preprocessor", cradleOptsProg = CradleAction: Cabal-Helper-Stack}
2020-01-27 00:43:27.9500122 [ThreadId 3] - Executing Stack GHC with args: --numeric-version
2020-01-27 00:43:28.4603862 [ThreadId 3] - Executing Stack GHC with args: --print-libdir
2020-01-27 00:43:28.957058 [ThreadId 3] - New cradle: C:\Users\caleb\Documents\deepdecompilerproject\dd-c-preprocessor\test\Spec.hs
2020-01-27 00:43:28.960053 [ThreadId 3] - Cabal-Helper
@calebh
calebh / model.py
Created May 3, 2020 19:41
Bizzare PyTorch memory issue
import torch
import pickle
import os
import random
import sourcenode
import torch.nn as nn
import torch.utils.checkpoint
import torch.utils.data
import math
import objprocessor