Skip to content

Instantly share code, notes, and snippets.

View ranjitjhala's full-sized avatar

Ranjit Jhala ranjitjhala

View GitHub Profile
@ranjitjhala
ranjitjhala / FingSimple.hs
Last active January 18, 2019 18:12
Finger Tree - Liquid Haskell
{-@ LIQUID "--no-termination" @-}
{-@ LIQUID "--reflection" @-}
{-@ LIQUID "--no-adt" @-}
{- LIQUID "--diff" @-}
{-@ LIQUID "--ple" @-}
module FingerTree where
import Language.Haskell.Liquid.ProofCombinators
{-# LANGUAGE ViewPatterns #-}
module InTex where
import Text.Pandoc.JSON
import Text.Pandoc
import Data.List
main :: IO ()
main = toJSONFilter readFootnotes
module AVL where
{-@ data Tree [ht] = Nil | Tree (x::Int) (l::Tree) (r::Tree) @-}
data Tree = Nil | Tree Int Tree Tree
{-@ height :: t:Tree -> {v:Int | v = ht t} @-}
height :: Tree -> Int
height Nil = 0
height (Tree _ l r) = (if height l > height r then 1 + height l else 1 + height r)