Skip to content

Instantly share code, notes, and snippets.

@Gabriel439
Gabriel439 / tree.dhall
Created Dec 18, 2018
Merry Christmas!
View tree.dhall
let Prelude =
https://prelude.dhall-lang.org/package.dhall
sha256:534e4a9e687ba74bfac71b30fc27aa269c0465087ef79bf483e876781602a454
let repeat =
λ(t : Text)
→ λ(n : Natural)
→ Prelude.`Text`.concat (Prelude.`List`.replicate n Text t)
let spaces = repeat " "
@Gabriel439
Gabriel439 / package.dhall
Created Apr 7, 2018
The Cabal file format encoded as a Dhall type
View package.dhall
let Version = ∀(Version : Type) → ∀(v : Text → Version) → Version
in let VersionRange =
∀(VersionRange : Type)
→ ∀(anyVersion : VersionRange)
→ ∀(noVersion : VersionRange)
→ ∀(thisVersion : Version → VersionRange)
→ ∀(notThisVersion : Version → VersionRange)
→ ∀(laterVersion : Version → VersionRange)
→ ∀(earlierVersion : Version → VersionRange)
@Gabriel439
Gabriel439 / fibonacci.hs
Created Mar 25, 2018
Efficient fibonacci numbers using infinite precision integer arithmetic
View fibonacci.hs
import Numeric.Natural (Natural)
import qualified Data.Semigroup
-- | @fibonacci n@ computes the @nth@ fibonacci number efficiently using infinite
-- precision integer arithmetic
--
-- Try @fibonacci 1000000@
fibonacci :: Natural -> Natural
fibonacci n = x01 (Data.Semigroup.mtimesDefault n m)
@Gabriel439
Gabriel439 / Main.purs
Last active Mar 31, 2018
Purescript Flare - Simon example
View Main.purs
module Main where
import Data.Array ((..), reverse)
import Data.Int (toNumber)
import Flare (UI, radioGroup)
import Flare.Drawing (runFlareDrawing)
import Graphics.Drawing
import Graphics.Drawing.Font (font, sansSerif, bold)
import Math (cos, sin, pi)
import Prelude
View gist:011424bec6d839d98b0b
import Numeric.AD
assert = print
eval = id
main = do
let a x = 2 * x^2 + 3
let b = eval a 1
assert (b == 5) -- Prints `True`
@Gabriel439
Gabriel439 / gist:be7c8cfc536be91ef4f5
Last active Aug 29, 2015
Quick annah walkthrough
View gist:be7c8cfc536be91ef4f5
-- Example Annah programs and their reductions
-- I'll start with simple non-recursive data types so that you can get a feel for the syntax and then work up to recursive data
-- types followed by mutually recursive types
-- Example #1: Bool, the type
$ annah
type Bool
data True
data False
in Bool
You can’t perform that action at this time.