Skip to content

Instantly share code, notes, and snippets.

@archaeron
archaeron / test.idr
Last active December 21, 2015 11:07
Crashing Idris ide-mode
module Test
a
@archaeron
archaeron / gist:cec8341e626cf4e7cd44
Created May 20, 2015 17:00
long Idris ide-mode answer
000473(:return (:ok "Data type Nat : Type
Unary natural numbers
Constructors:
Z : Nat
Zero
S : Nat -> Nat
Successor
" ((10 3 ((:name "Prelude.Nat.Nat") (:implicit :False) (:decor :type) (:doc-overview "Unary natural numbers") (:type "Type") (:namespace "Prelude.Nat"))) (16 4 ((:decor :type) (:type "Type") (:doc-overview "The type of types") (:name "Type"))) (70 1 ((:name "Prelude.Nat.Z") (:implicit :False) (:decor :data) (:doc-overview "Zero") (:type "Nat") (:namespace "Prelude.Nat"))) (74 3 ((:name "Prelude.Nat.Nat") (:implicit :False) (:decor :type) (:doc-overview "Unary natural numbers") (:type "Type") (:namespace "Prelude.Nat"))) (104 1 ((:name "Prelude.Nat.S") (:implicit :False) (:decor :data) (:doc-overview "Successor") (:type "Nat -> Nat") (:namespace "Prelude.Nat"))) (108 3 ((:name "Prelude.Nat.Nat") (:implicit :False) (:decor :type) (:doc-overview "Unary natural numbers") (:type "Type") (:namespace "Prelude.Nat"))) (115 3 ((:name "Prelude.Nat.Nat") (:
@archaeron
archaeron / gist:6229708
Last active December 21, 2015 01:39
Functors and Monoids
class Monoid
mempty: ->
throw new Error "mempty not implemented"
mappend: ->
throw new Error "mappend not implemented"
mconcat: ->
throw new Error "mconcat not implemented"
class Option extends Monoid
mempty: ->
@archaeron
archaeron / gist:5928233
Created July 4, 2013 14:27
map over list with options
let optionize f =
function
| None -> None
| Some(x) -> Some(f x)
let newListMap f list = List.map (optionize f) list
let listWithNull = [Some 0; Some 6; Some 3; None; Some 34; None; Some 1]
let square x = x*x