This file contains 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 Main where | |
data Tree a = Leaf a | Node (Tree a) (Tree a) | |
deriving (Eq, Show) | |
tree = Node (Leaf "a") (Node (Leaf "b") (Node (Leaf "c") (Leaf "d"))) | |
countTree :: Tree a -> Integer | |
countTree (Leaf _) = 1 | |
countTree (Node l r) = countTree l + countTree r |
This file contains 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
fake_list = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91] | |
def has_elem(x, xs): | |
length = len(xs) - 1 | |
right = length | |
left = 0 | |
mid = (right - left) / 2 | |
while True: |
This file contains 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
optAlignments' :: String -> String -> [AlignmentType] | |
optAlignments' xs ys = snd $ get (length xs) (length ys) | |
where | |
get i j = table !! i !! j | |
table = [[ entry i j | j <- [0..] ] | i <- [0..] ] | |
entry :: Int -> Int -> (Int, [AlignmentType]) | |
entry i j | |
| i == 0 && j == 0 = (0, [([], [])]) | |
| i == 0 = (j * scoreSpace, (attachTails '-' y . snd) $ get 0 (j-1)) | |
| j == 0 = (i * scoreSpace, (attachTails x '-' . snd) $ get (i-1) 0) |
This file contains 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
➜ RealParser git:(master) ✗ nix-shell -A RealParser.env | |
[nix-shell:~/git/RealParser]$ runhaskell Setup.hs configure | |
Configuring RealParser-0.1.0.0... | |
clang-5.0: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument] | |
[nix-shell:~/git/RealParser]$ runhaskell Setup.hs repl | |
Setup.hs: The 'repl' command does not support multiple targets at once. | |
[nix-shell:~/git/RealParser]$ |
This file contains 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 TemplateHaskell #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
module Parser | |
( Parser (..), execParser, runParser | |
, ParseError (..), unexpected | |
, ParseState (..), input, location, previousToken, indentation | |
-- Parser functions | |
, char, satisfy, letter, digit, number, float -- Primitives |
This file contains 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 Control.Lens | |
import Test.Tasty | |
import Test.Tasty.HUnit | |
import Parser | |
defaultPs :: ParseState | |
defaultPs = ParseState "" (0,0) "" [] | |
ps1 :: ParseState | |
ps1 = input .~ ".123" $ defaultPs |
This file contains 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
/Users/ehammarstrom/git/RealParser/test/Spec.hs:18:27: error: | |
• No instance for (transformers-0.5.2.0:Control.Monad.Trans.Error.Error | |
ParseError) | |
arising from a use of ‘satisfy’ | |
• In the first argument of ‘runParser’, namely | |
‘(satisfy "dot" (== '.'))’ | |
In the expression: runParser (satisfy "dot" (== '.')) ps1 | |
In an equation for ‘t1’: | |
t1 = runParser (satisfy "dot" (== '.')) ps1 | |
| |
This file contains 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
{ | |
"vim.normalModeKeyBindingsNonRecursive": [ | |
{ "before": ["t"], "after": ["g", "j"] }, | |
{ "before": ["n"], "after": ["g", "k"] }, | |
{ "before": ["h"], "after": ["h"] }, | |
{ "before": ["s"], "after": ["l"] }, | |
{ "before": ["S"], "after": ["L"] }, | |
{ "before": ["j"], "after": ["s"] }, | |
{ "before": ["J"], "after": ["S"] }, | |
{ "before": ["T"], "after": ["J"] }, |
This file contains 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
[ | |
{ | |
"key": "shift+ctrl+h", | |
"command": "workbench.action.navigateLeft" | |
}, | |
{ | |
"key": "shift+ctrl+s", | |
"command": "workbench.action.navigateRight" | |
}, | |
{ |
This file contains 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
(let ((bootstrap-file | |
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | |
(bootstrap-version 4)) | |
(unless (file-exists-p bootstrap-file) | |
(with-current-buffer | |
(url-retrieve-synchronously | |
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | |
'silent 'inhibit-cookies) | |
(goto-char (point-max)) | |
(eval-print-last-sexp))) |