Skip to content

Instantly share code, notes, and snippets.

@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
@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: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 / test.idr
Last active December 21, 2015 11:07
Crashing Idris ide-mode
module Test
a
@archaeron
archaeron / syntax-highlighting-tests.idr
Created May 26, 2015 20:55
Syntax highlighting tests
module Main
import Data.Vect
main : IO ()
main = putStrLn "Hello world\n\o44\5\xa4"
zipWithF : (a -> b -> c) -> List a -> List b -> List c
zipWithF f xs ys = ?zipWithF_rhs_2
@archaeron
archaeron / bug_test.idr
Last active August 29, 2015 14:25
Idris 0.9.18 bug?
module Test
a : (String -> Either String String) -> String
a b =
case b of
Left err => err
Right v => v
@archaeron
archaeron / Main.idh
Created August 19, 2015 23:12
Highlighting
((((:filename ".\\Highlight\\Main.idr") (:start 1 8) (:end 1 22)) ((:namespace "Highlight.Main") (:decor :module) (:source-file "C:\\Users\\Nicolas\\Documents\\Programming\\Idris\\idris-code-highlighter\\src\\Highlight\\Main.idr"))) (((:filename ".\\Highlight\\Parser.idr") (:start 1 8) (:end 1 24)) ((:namespace "Highlight.Parser") (:decor :module) (:source-file "C:\\Users\\Nicolas\\Documents\\Programming\\Idris\\idris-code-highlighter\\src\\Highlight\\Parser.idr"))) (((:filename ".\\Highlight\\Regions.idr") (:start 1 8) (:end 1 25)) ((:namespace "Highlight.Regions") (:decor :module) (:source-file "C:\\Users\\Nicolas\\Documents\\Programming\\Idris\\idris-code-highlighter\\src\\Highlight\\Regions.idr"))) (((:filename ".\\Highlight\\Regions.idr") (:start 1 8) (:end 1 25)) ((:namespace "Highlight.Regions") (:decor :module) (:source-file "C:\\Users\\Nicolas\\Documents\\Programming\\Idris\\idris-code-highlighter\\src\\Highlight\\Regions.idr"))) (((:filename ".\\Highlight\\Formats.idr") (:start 1 8) (:end 1 25)) ((:
@archaeron
archaeron / keybase.md
Created October 6, 2017 12:48
keybase.md

Keybase proof

I hereby claim:

  • I am archaeron on github.
  • I am archaeron (https://keybase.io/archaeron) on keybase.
  • I have a public key ASCMJritEyCIwn247mMKQGggmI1uINWwo7qI8QMYtHCFUgo

To claim this, I am signing this object:

@archaeron
archaeron / default.nix
Created March 5, 2018 13:19
Ocaml Nix
with import <nixpkgs> {};
let
ocamlPackages = pkgs.recurseIntoAttrs pkgs.ocamlPackages_4_03;
ocamlVersion = (builtins.parseDrvName ocamlPackages.ocaml.name).version;
findlibSiteLib = "${ocamlPackages.findlib}/lib/ocaml/${ocamlVersion}/site-lib";
ocamlInit = pkgs.writeText "ocamlinit" ''
let () =
try Topdirs.dir_directory "${findlibSiteLib}"
with Not_found -> ()
@archaeron
archaeron / README.md
Last active July 24, 2018 13:17
stack2nix
  1. stack2nix . > nix/stack.nix
  2. nix-shell default.nix -A api