This file contains hidden or 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
| ;; Macro to define algebraic data types | |
| ;; Usage: | |
| ;; (defdata Maybe | |
| ;; Nothing ; Nullary constructor (no arguments) | |
| ;; [Just val] ; N-ary constructor with positional fields | |
| ;; (Good a b c)) ; Record constructor with named fields | |
| ;; | |
| ;; This will create a local table `Maybe` with constructors: | |
| ;; Maybe.Nothing() ; Returns {:variant "Nothing"} | |
| ;; Maybe.Just(val) ; Returns {:variant "Just" :fields [val]} |
This file contains hidden or 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
| Haskell 54 mins βββββββββββββββββββββ 96.0% | |
| Text 2 mins βββββββββββββββββββββ 4.0% |
This file contains hidden or 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
| open import Level using (_β_) | |
| open import Function using (_β_) | |
| open import Data.Vec using (Vec; []; _β·_; foldr) | |
| open import Data.Nat using (β; zero; suc; _+_) | |
| open import Data.Nat.Properties.Simple using (+-right-identity; +-suc) | |
| open import Data.Sum using (_β_; injβ; injβ) | |
| open import Data.Product using (β; _Γ_; _,_; projβ; projβ) | |
| open import Data.Empty using (β₯-elim) | |
| open import Relation.Nullary using (Dec; yes; no; Β¬_) | |
| open import Relation.Binary using (module DecTotalOrder; DecTotalOrder; Rel) |
This file contains hidden or 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 Lib where | |
| -- 4 | |
| -- >>> euler 10 | |
| -- | euler's totient function | |
| -- | |
| -- euler's totient function is defined as the number of positive integers | |
| -- less than or equal to n which are coprime to n. |
This file contains hidden or 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
| {-# LANGUAGE ViewPatterns #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| {-# LANGUAGE DeriveFoldable #-} | |
| {-# LANGUAGE DeriveTraversable #-} |