Skip to content

Instantly share code, notes, and snippets.

@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 / 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: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: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

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:

@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},
@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
@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) ->
data Strategy : Type where
MkStrategy : (t : Type -> Type) ->
(delay : (a : Type) -> a -> t a) ->
(force : (a : Type) -> t a -> a) ->
Strategy
strategy : Strategy -> Type -> Type
strategy (MkStrategy t delay force) = t
delay : {s : Strategy} -> {a : Type} -> a -> strategy s a
@edwinb
edwinb / stream.idr
Last active October 26, 2017 22:01
concurrent counting
module Main
import Effects
import Effect.StdIO
import System.Protocol
data Command = Next | SetIncrement | Stop
count : Protocol ['Client, 'Server] ()