Skip to content

Instantly share code, notes, and snippets.

Avatar
🐺
Nothing is more permanent than a temporary solution

Dimitri Sabadie phaazon

🐺
Nothing is more permanent than a temporary solution
View GitHub Profile
View ToBin.hs
toBin8 :: Int8 -> Integer
toBin8 x =
y .&. 1
+ (y `shiftR` 1 .&. 1) * 10
+ (y `shiftR` 2 .&. 1) * 100
+ (y `shiftR` 3 .&. 1) * 1000
+ (y `shiftR` 4 .&. 1) * 10000
+ (y `shiftR` 5 .&. 1) * 100000
+ (y `shiftR` 6 .&. 1) * 1000000
+ (y `shiftR` 7 .&. 1) * 10000000
@phaazon
phaazon / dylanmusk.rs
Last active Jan 3, 2020
For Dylan Musk
View dylanmusk.rs
// A depends on B-0.1 and C-0.1
// B depends on C-0.1
// in C
struct Foo;
struct Bar;
// in A
fn foo(_: Foo, _: Bar);
View Selective.hs
-- Why not this implementation?
selectM :: (Monad f) => f (Either a b) -> f (a -> b) -> f b
selectM x y = do
e <- x
case e of
Left a -> fmap ($a) y
Right b -> b <$ y
View Selective.hs
-- Why not this implementation?
selectM :: (Monad f) => f (Either a b) -> f (a -> b) -> f b
selectM x y = do
e <- x
case e of
Left a -> fmap ($a) y
Right b -> fmap (const b) y
View a.cpp
#include <iostream>
#include <string>
struct BordelLand {
BordelLand(bool x): tag(Graffiti::A), a(x) {}
BordelLand(char x): tag(Graffiti::B), b(x) {}
BordelLand(float x): tag(Graffiti::C), c(x) {}
template <typename F> void pattern_a(F f) {
if (tag == Graffiti::A) {
View custom_deserialize_serde.rs
use serde::de::{Deserialize, Deserializer, Error, Visitor};
use std::fmt;
use serde_json::de::from_str;
#[derive(Clone, Debug, Eq, PartialEq)]
enum YourFancyEnum {
Foo,
Bar,
Zoo,
View keybase.md

Keybase proof

I hereby claim:

  • I am phaazon on github.
  • I am phaazon (https://keybase.io/phaazon) on keybase.
  • I have a public key whose fingerprint is 3943 DF2A 2E41 24B4 5702 E6BC 4F28 29BB 996A 2EED

To claim this, I am signing this object:

View NT.hs
{-# LANGUAGE RankNTypes #-}
-- A natural transformation.
data NT f g = NT { nt :: forall a. f a -> g a }
-- Natural transformation from Maybe to [].
maybeListNT :: NT Maybe []
maybeListNT = NT (maybe [] pure)
View a.rs
fn correct<F>(f: F) where F: for<'a> FnOnce(&'a u32) {
f(&3)
}
fn dafuck<F>(f: F) where for<'a> F: FnOnce(&'a u32) {
f(&3)
}
fn main() {
correct(|x| println!("{}", x));
View enkuler_de_rire.go
package main
import "fmt"
func fibonacci() func() int {
a := 0
b := 1
return func() int {
c := a
a, b = b, a + b
You can’t perform that action at this time.