This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main | |
{- | |
Compile with: | |
idris --package javascript --target javascript test.idr -o test.js | |
<html> | |
<head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module JSON | |
import Data.SortedMap | |
data JSONType: Type where | |
JSONArray : Vect JSONType n -> JSONType | |
JSONString : JSONType | |
JSONNumber : JSONType | |
JSONBool : JSONType | |
JSONObject : SortedMap String JSONType -> JSONType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bezier | |
Point : Type -> Nat -> Type | |
Point = Vect | |
-- parametric line between two points: | |
line : Num a => Point a d -> Point a d -> a -> Point a d | |
line p q t = zipWith interpolate p q | |
where interpolate a b = (1 - t)*a + t*b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total | |
fold_length : List a -> Nat | |
fold_length = foldl (\n, _ => S n) Z | |
total | |
foldr_reduce : (n : Nat) -> (xs : List a) -> | |
let f : (Nat -> a -> Nat) = (\n, _ => S n) in | |
S (foldr (flip (.) . flip f) id xs n) = foldr (flip (.) . flip f) id xs (S n) | |
foldr_reduce n Nil = refl | |
foldr_reduce n (x :: xs) = let ih = foldr_reduce (S n) xs in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main | |
FIO : FTy | |
FIO = FAny (IO ()) | |
foo : String -> String -> IO () | |
foo a b = putStrLn $ a ++ b | |
test : String -> (String -> String -> IO ()) -> IO () | |
test s f = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Vect | |
import scala.language.higherKinds | |
sealed trait Nat | |
sealed trait Z extends Nat | |
sealed trait S[N <: Nat] extends Nat | |
trait Exists[A, +B[_ <: A]] { | |
type fst <: A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
recTestHelper : Integer -> Integer -> Integer | |
recTestHelper n 0 = n | |
recTestHelper n m = recTestHelper (n * m) (m - 1) | |
*/ | |
var __IDR__wnurecTesturecTestHelper0swnurecTesturecTestHelper0 = function(me0,me1){ | |
var __var_2 = __IDRRT__EVALTC(me1) | |
if (__var_2.equals(__IDRRT__ZERO)) { | |
return me0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var __IDR__BoolPreludenuboolElim = function(me0,me1,me2,me3){ | |
var __var_4 = __IDRRT__tailcall(function(){ | |
return __IDR__mEVAL0(me1) | |
}); | |
if (__var_4 instanceof __IDRRT__Con && 0 == __var_4.tag) { | |
return me3; | |
} else if (__var_4 instanceof __IDRRT__Con && 1 == __var_4.tag) { | |
return me2; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total | |
isElem' : DecEq a => (e : a) -> (t : Tree a) -> Dec (IsElem e t) | |
isElem' x Leaf = No $ \p => noElemInLeaf x p | |
where | |
total | |
noElemInLeaf : (x : a) -> IsElem x Leaf -> _|_ | |
noElemInLeaf x Here impossible | |
isElem' x (Branch l y r) with (decEq x y) | |
isElem' x (Branch l x r) | Yes refl = Yes Here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var __IDRLT__APPLY65610 = function(mfn0,marg0){ | |
return new __IDRRT__Cont(function(){ | |
return __IDRRT__print(mfn0.vars[0]) | |
}) | |
} | |
var __IDRLT__APPLY65611 = function(mfn0,marg0){ | |
return new __IDRRT__Cont(function(){ | |
return __IDR__mAPPLY0(mfn0.vars[1],marg0) | |
}) |