Skip to content

Instantly share code, notes, and snippets.

View rampion's full-sized avatar

Noah Luck Easterly rampion

  • Mercury Technologies
View GitHub Profile

This is a sentence on a single line with a trailing space. Here is a sentence on the next line.

This is a sentence on a single line without a trailing space. Here is a sentence on the next line.

This is a sentence on a single line with two a trailing spaces.
Here is a sentence on the next line.

{-# OPTIONS_GHC -Wall -Wextra -Werror #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
module Partition where
import Data.Functor.Identity
import Data.Kind
{-# OPTIONS_GHC -Wall -Wextra -Werror #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeFamilies #-}
module Partition where
import Data.Kind
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wall -Wextra -Werror #-}
-- https://exercism.org/tracks/haskell/exercises/crypto-square
module CryptoSquare where
import Data.Char (isLower, toLower)
@rampion
rampion / Magnitude.hs
Created May 13, 2024 14:03
Lazy calculation of list length; update of https://gist.github.com/rampion/6337593
{-# OPTIONS_GHC -Wall -Wextra -Werror #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
-- |
-- Types for lazy length computation and comparison
--
-- >>> length (replicate 5 'a')
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StandaloneKindSignatures #-}
@rampion
rampion / ZipWith.hs
Last active July 8, 2021 03:52
Two implementations of a variadic `zipWith` function, based on inferring the type using either the argument or the return type
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
module ZipWith where
import Control.Applicative (ZipList (..))
import Prelude hiding (zipWith)
@rampion
rampion / Lib.hs
Last active May 24, 2021 00:55
ShortestLongest
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wall -Wextra -Werror -Wno-name-shadowing -Wno-unused-top-binds #-}
module Lib
( shortestLongest,
)
where
@rampion
rampion / HyperList.hs
Last active August 5, 2024 15:41
Demonstration of how the Hyperfunction implementation of list works.
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall -Werror -Wextra -Wno-name-shadowing #-}
module HyperList where
import Data.Function ((&))
newtype a -&> b = Hyp {invoke :: (b -&> a) -> b}
@rampion
rampion / HyperPhases.hs
Created May 16, 2021 08:04
Breadth-first traversal of a rose tree using a Scott encoding of the Phases applicative
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE Rank2Types #-}
{-# OPTIONS_GHC -Wall -Werror -Wextra -Wno-name-shadowing #-}
module HyperPhases where
import Control.Applicative (liftA2)
import Data.Functor ((<&>))
newtype Phases f a = Phases