As example, we're using the proof that there's a path between homotopy1 and homotopy2 from Exercise 4.
Instead of looking at a circle, let's look at a general path
A path is a continuous function of type
| #!/usr/bin/env bash | |
| # Generate bookmark names bases on jj change descriptions | |
| # init vars | |
| api_key="${OPENAI_API_KEY}" | |
| base_rev="${1:-trunk()}" | |
| if [ -z "$api_key" ]; then | |
| echo "Error: OPENAI_API_KEY environment variable not set" >&2 |
| {-# LANGUAGE BlockArguments #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| module Filter where | |
| import Data.Profunctor | |
| import Data.Profunctor.Product | |
| import Prelude hiding (filter) | |
| import Control.Applicative |
| /* | |
| Constructive proof of Roger's fixed-point theorem in Javascript | |
| =============================================================== | |
| N.B. You can load this file in node.js using `.load roger.js` to use the | |
| functions defined here in a REPL. | |
| Definition (Program) | |
| -------------------- | |
| Below, a "program" will always be a Javascript function of one argument. |
As example, we're using the proof that there's a path between homotopy1 and homotopy2 from Exercise 4.
Instead of looking at a circle, let's look at a general path
A path is a continuous function of type
| {-# LANGUAGE AllowAmbiguousTypes #-} | |
| {-# LANGUAGE MonadComprehensions #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE DeriveDataTypeable #-} | |
| import Data.Data | |
| import Data.Foldable | |
| import Data.Functor | |
| import Data.Maybe |
| data WindowSize = MkWindowSize { windowWidth :: !Natural | |
| , windowHeight :: !Natural | |
| } | |
| makeRioClassy ''WindowSize | |
| -- This will generate | |
| -- class (HasWindowWidth env, HasWindowHeight env) | |
| -- => HasWindowSize env where windowSizeL :: Lens' env WindowSize | |
| -- class HasWindowWidth env where ... (method signatures omitted for brevity from here on out) | |
| -- class HasWindowHeight env | |
| -- (as well as associated `id` instances, omitted for brevity for this and the other types) |
| -- Inspired by https://github.com/goldfirere/video-resources/blob/main/2021-07-06-zipWith/ZipWith.hs | |
| {-# LANGUAGE StandaloneKindSignatures, DataKinds, TypeOperators, | |
| TypeFamilies, UndecidableInstances, GADTs, ScopedTypeVariables, | |
| TypeApplications, FlexibleInstances, FlexibleContexts, | |
| ConstraintKinds, FunctionalDependencies, AllowAmbiguousTypes #-} | |
| module Lift where | |
| import Data.Kind |
| {-# LANGUAGE ScopedTypeVariables | |
| , ViewPatterns | |
| , LambdaCase | |
| , BlockArguments | |
| , StandaloneKindSignatures | |
| , GADTs | |
| , TypeOperators | |
| , ImportQualifiedPost | |
| , UndecidableInstances | |
| , DerivingVia |
| {-# LANGUAGE NumDecimals, BlockArguments #-} | |
| import System.Environment | |
| import Data.List | |
| f 0 = (length .) . filter | |
| f 1 = count | |
| f 2 = count' | |
| f 3 = count'' |
| {-# LANGUAGE GADTs, TypeFamilies, DataKinds, TypeOperators, StandaloneDeriving #-} | |
| module Dependent where | |
| data Nat = Z | S Nat | |
| data Vec (n :: Nat) a where | |
| Nil :: Vec Z a | |
| Cons :: a -> Vec n a -> Vec (S n) a |