Skip to content

Instantly share code, notes, and snippets.

@deech
deech / liftM2Equivalent.hs
Created July 2, 2016 17:52
liftM2 equivalent
monadic = do
x <- [0,1]
y <- [0,2]
return (x + y)
applicative = (+) <$> [0,1] <*> [0,2]
comprehension = [(x + y) | x <- [0,1], y <- [0,2] ]
main = do
print monadic
print applicative
print comprehension
Most remember Pieter Hintjens for his messaging protocols. I don't know anything about that,
but I credit him with rekindling my love of programming in general, Lisp and functional programming
in one fell swoop about 17 years ago.
He did this by writing 'Libero', a mid-90's C program that took an ASCII diagram of a state machine
and produced code that ran that machine in a remarkable number of languages including 'sh', 'python',
'C' and many more. Some of them are listed on the original page (https://imatix-legacy.github.io/libero/).
I discovered in the early 00's and it fascinated me because was a unique combination of code generation
and what is now called purely functional programming.
@deech
deech / union.shen
Created November 1, 2016 01:34
Shen Union type
(datatype whisky
if (element? X [bourbon scotch])
________________________________
X : whisky;)
(datatype beer
if (element? X [lager stout])
______________________________
X : beer;)
@deech
deech / EmacsConfig
Created November 23, 2016 22:13
Emacs Config
;; -*- mode: dotspacemacs -*-
;; This file is loaded y Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (ie. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
@deech
deech / typeclass-repl.hs
Created February 12, 2017 15:17
Typeclasses in the REPL.
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /tmp/ghci7261/ghci-script
Prelude> class Foo a where { foo :: a -> Int }
Prelude> instance Foo () where { foo _ = 1 }
Prelude> f = foo ()
Prelude> class Foo a where { foo :: a -> IO () }
Prelude> f
1
(datatype is-prime
if (is-prime? N)
N : number;
==============
N : prime;)
(define is-prime?
X -> (prime* X (/ X 2) 2) where (number? X)
_ -> false)
diff --git a/c-src/Fl_C.h b/c-src/Fl_C.h
index 963bc04..9485c6c 100644
--- a/c-src/Fl_C.h
+++ b/c-src/Fl_C.h
@@ -257,6 +257,7 @@ EXPORT {
FL_EXPORT_C(void ,Fl_release_widget_pointer)(fl_Widget w);
FL_EXPORT_C(void ,Fl_clear_widget_pointer)(fl_Widget w);
FL_EXPORT_C(void ,Fl_clear_widget_pointer)(fl_Widget w);
+#if FL_API_VERSION == 10304
FL_EXPORT_C(void ,Fl_set_box_color)(Fl_Color c);
curl -X PUT -H "Content-Type: application/x-tar" -H "Content-Encoding: gzip" --data-binary @"packagename-packageversion-docs.tar.gz" "https://usernae:[email protected]/package/packagename-packageversion/docs"
@deech
deech / D Compile time TCO
Created July 7, 2017 20:53
D Compile Time TCO
import std.stdio;
double factorial (double i)
{
if (i == 1) {
return 1;
}
else {
return (i * factorial(i - 1));
}
3/home/deech/Pharo/vms/70-x64/lib/pharo/5.0-201806281256/pharo
Pharo VM version: 5.0-201806281256 Thu Jun 28 13:04:44 UTC 2018 gcc 4.8 [Production Spur 64-bit VM]
Built from: CoInterpreter VMMaker.oscog-eem.2401 uuid: 29232e0e-c9e3-41d8-ae75-519db862e02c Jun 28 2018
With: StackToRegisterMappingCogit VMMaker.oscog-eem.2401 uuid: 29232e0e-c9e3-41d8-ae75-519db862e02c Jun 28 2018
Revision: VM: 201806281256 https://github.com/OpenSmalltalk/opensmalltalk-vm.git Date: Thu Jun 28 14:56:30 2018 CommitHash: a8a1dc1 Plugins: 201806281256 https://github.com/OpenSmalltalk/opensmalltalk-vm.git
Build host: Linux travis-job-46342785-b1c1-4811-8c3c-9b2a88ae7ecc 4.4.0-101-generic #124~14.04.1-Ubuntu SMP Fri Nov 10 19:05:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
plugin path: [default: /home/deech/Pharo/vms/70-x64/lib/pharo/5.0-201806281256/]
C stack backtrace & registers: