Skip to content

Instantly share code, notes, and snippets.

@edwinb
edwinb / nestedrec.idr
Last active August 29, 2015 14:00
Nested record update syntax
record Person : Nat -> Type where
MkPerson : (name : String) ->
(age : Nat) ->
Person age
record Event : Type where
MkEvent : (name : String) -> (organiser : Person a) -> Event
record Meeting : Int -> Type where
MkMeeting : (event : Event) ->
@edwinb
edwinb / lt.idr
Last active August 29, 2015 13:59
Less than
-- We could define the relation like this:
data LessThan : Nat -> Nat -> Type where
LT_Z : LessThan Z (S m)
LT_S : LessThan n m -> LessThan (S n) (S m)
-- Then calculate a proof, if one exists:
isLessThan : (m : Nat) -> (n : Nat) -> Maybe (LessThan m n)
isLessThan Z Z = Nothing
@article{JFP:9060502,
author = {BRADY,EDWIN},
title = {Idris, a general-purpose dependently typed programming language: Design and implementation},
journal = {Journal of Functional Programming},
volume = {23},
issue = {05},
month = {9},
year = {2013},
issn = {1469-7653},
pages = {552--593},

Keybase proof

I hereby claim:

  • I am edwinb on github.
  • I am edwinb (https://keybase.io/edwinb) on keybase.
  • I have a public key whose fingerprint is 9FDE 3D18 203F 0CFA DD7A A817 F219 A102 9E17 61E3

To claim this, I am signing this object:

@edwinb
edwinb / gist:8882942
Created February 8, 2014 12:27
Half baked idea: Inference command?
foo : (xs : Vect n a) -> (ys : Vect m a) -> ?noIdea
foo xs ys = xs ++ ys
Currently this gives:
Can't unify
Vect (n + m) a
with
?noIdea
@edwinb
edwinb / gist:8829429
Created February 5, 2014 17:49
Marshaling
class Marshal val chan where
sendType : Type -> Type
recvType : Type -> Type
marshal : val -> sendType val
unmarshal : sendType val -> recvType val
@edwinb
edwinb / gist:8812278
Created February 4, 2014 21:00
Parser trace
(./DB/SQLite/SQLiteNew.idr:19:13,"Type\n")
(./DB/SQLite/SQLiteNew.idr:19:13,"Type\n")
(./DB/SQLite/SQLiteNew.idr:20:13,"List (List DBVal)\n")
(./DB/SQLite/SQLiteNew.idr:20:19,"List DBVal)\n")
(./DB/SQLite/SQLiteNew.idr:22:10,"Type\n")
(./DB/SQLite/SQLiteNew.idr:22:10,"Type\n")
(./DB/SQLite/SQLiteNew.idr:23:10,"String\n")
(./DB/SQLite/SQLiteNew.idr:25:15,"Type\n")
(./DB/SQLite/SQLiteNew.idr:25:15,"Type\n")
(./DB/SQLite/SQLiteNew.idr:26:15,"String\n")
@edwinb
edwinb / gist:8801403
Created February 4, 2014 10:40
ffi diff
Ran ffi001...FAILURE
2c2
< 0.9995736030415051 : Float
---
0.9995736030415051 : Float
make[1]: *** [ffi001.test] Error 1
@edwinb
edwinb / err
Created January 27, 2014 00:08
Better error messages...
Problem:
--------
You tried to use the random number generator effect when it wasn't available.
New error message:
------------------
Expr.idr:31:6:When elaborating right hand side of eval:
Can't solve goal
@edwinb
edwinb / gist:8551794
Last active January 4, 2016 01:59
minus, with erasue
module erase
data LessThan : Nat -> Nat -> Type where
LtO : LessThan Z (S k)
LtS : LessThan x y -> LessThan (S x) (S y)
minus : (x : Nat) -> (y : Nat) -> LessThan y x -> Nat
minus (S k) Z LtO = S k
minus (S k) (S j) (LtS z) = minus k j