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 PatternSynonyms, ViewPatterns #-} | |
| {-# OPTIONS_GHC -Wall #-} | |
| import Data.List | |
| import Data.Ord | |
| isPalindrome :: Eq a => [a] -> Bool | |
| isPalindrome xs = xs == reverse xs | |
| lps, lps' :: Eq a => [a] -> [a] | |
| lps = maximumBy (comparing length) . filter isPalindrome . subsequences |
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
| {- cabal: | |
| build-depends: base, recover-rtti, tasty-bench, tasty-bench-fit | |
| -} | |
| {-# LANGUAGE GHC2021, GADTs, DataKinds, LambdaCase, TypeFamilies #-} | |
| {-# OPTIONS_GHC -Wall #-} | |
| -- DATA-DEPENDENT PARSING WITH VARIABLES | |
| import Prelude hiding (Monad (..)) | |
| import Data.Char (intToDigit) |
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 GHC2021, GADTs, DataKinds #-} | |
| import Control.Monad (ap, (>=>), replicateM_, guard) | |
| import Control.Applicative | |
| import Prelude hiding (or) | |
| import Data.Kind | |
| import Data.Char | |
| asumMap :: Alternative f => (a -> f b) -> [a] -> f b | |
| asumMap f x = asum (map f x) |
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 GHC2021, GADTs, DataKinds #-} | |
| import Control.Monad (ap, (>=>)) | |
| import Control.Applicative | |
| import Prelude hiding (or) | |
| import Data.Kind | |
| import Data.Char | |
| type Ctx :: Type | |
| type Ctx = [Type] |
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
| {- cabal: | |
| build-depends: base, liquidhaskell == 0.9.6.* | |
| -} | |
| {- project: | |
| allow-newer: bytestring | |
| -} | |
| {-# LANGUAGE GHC2021 #-} | |
| {-# OPTIONS_GHC -Wall -fplugin=LiquidHaskell #-} | |
| -- Liquid Haskell checks termination for us, but you can disable it if you want. |
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
| {-# OPTIONS --guarded --rewriting --cubical -WnoUnsupportedIndexedMatch #-} | |
| module 1-Parser where | |
| open import 2-Guarded | |
| open import Data.Product hiding (_<*>_) | |
| open import Data.Char hiding (_≤_) | |
| open import Data.Bool hiding (_≤_) | |
| open import Function |
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 MagicHash #-} | |
| import GHC.Exts | |
| import Foreign | |
| import GHC.Word | |
| import Control.Arrow ((>>>)) | |
| rotl64 :: Word64 -> Int -> Word64 | |
| rotl64 (W64# x#) (I# i#) = W64# ((x# `uncheckedShiftL64#` i#) `or64#` (x# `uncheckedShiftRL64#` (64# -# i#))) |
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
| #!/usr/bin/env cabal | |
| {- cabal: | |
| build-depends: base >= 4.19, bytestring, primitive >= 0.9, mmap | |
| default-language: GHC2021 | |
| ghc-options: -Wall -O2 -fllvm | |
| -} | |
| {-# LANGUAGE ExtendedLiterals #-} | |
| {-# LANGUAGE MagicHash, UnboxedTuples, UnliftedDatatypes #-} | |
| import Data.ByteString (ByteString) |
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
| import qualified Data.Map.Strict as Map | |
| data Exp = Var String | Lam String Exp | App Exp String | Let String Exp Exp | |
| | Con String [String] | Case Exp (Map.Map String ([String], Exp)) | |
| deriving Show | |
| data State = State Heap Control Environment Stack deriving Show | |
| data Heap = Heap !Int !(Map.Map String (Exp, Environment)) deriving Show | |
| type Control = Exp |
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
| import Prelude hiding (until) | |
| import Test.Tasty.Bench | |
| {-# NOINLINE until #-} | |
| until :: (a -> Bool) -> (a -> a) -> a -> a | |
| until p f = go | |
| where | |
| go x | p x = x | |
| | otherwise = go (f x) |