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 ParseFull where | |
import Control.Applicative | |
import Data.Char | |
newtype Parser a = P (String -> [(a,String)]) | |
parse :: Parser a -> String -> [(a,String)] | |
parse (P p) inp = p inp | |
item :: Parser Char |
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 ShowExpression where | |
data Op = Add | Sub | Mul | Div | |
instance Show Op where | |
show Add = "+" | |
show Sub = "-" | |
show Mul = "*" | |
show Div = "/" |
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 Debug.Trace | |
subs :: [a] -> [[a]] | |
subs [] = [[]] | |
subs (x:xs) = yss ++ map (x:) yss | |
where yss = subs xs | |
interleave :: a -> [a] -> [[a]] | |
interleave x [] = [[x]] | |
interleave x (y:ys) = (x:y:ys) : map (y:) (interleave x ys) |
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 ShowExpression where | |
data Op = Add | Sub | Mul | Div | |
instance Show Op where | |
show Add = "+" | |
show Sub = "-" | |
show Mul = "*" | |
show Div = "/" |
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 ShowExpression | |
subs :: [a] -> [[a]] | |
subs [] = [[]] | |
subs (x:xs) = yss ++ map (x:) yss | |
where yss = subs xs | |
interleave :: a -> [a] -> [[a]] | |
interleave x [] = [[x]] |
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
split :: [a] -> [([a], [a])] | |
split [] = [] | |
split [_] = [] | |
split (x:xs) = ([x], xs) : [(x:ls, rs) | (ls, rs) <- split xs] | |
-- auxillary function combine in exprs: | |
combine :: Expr -> Expr -> [Expr] | |
combine l r = [App o l r | o <- ops] |
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
~/haskell/hutton] | |
$ ls | |
001_math 28_and_all.hs 59_chapt7.hs | |
002_notes 29_recurse.hs 59_chapt7i.hs | |
01_qsort.hs 30_merge.hs 60_redefines.hs | |
02_last.hs 31_mergeSample.hs 61_iterate.hs | |
03_init.hs 32_mSort.hs 62_parity.hs | |
04_abs.hs 33_core.hs 63_parity2.hs | |
05_twice.hs 34_core.hs 64_altMap.hs | |
06_patMatch.hs 35_basicMap.hs 65_luhn.hs |
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
λ > :l 75_taut.hs | |
[1 of 1] Compiling Main ( 75_taut.hs, interpreted ) | |
75_taut.hs:2:1: error: | |
Failed to load interface for ‘Propositions’ | |
Use -v to see a list of the files searched for. | |
Failed, modules loaded: none. | |
λ > |
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
I'm running $ stack build primality now , and getting the same very slow process that I got for $ stack new primality: | |
~/haskell $ stack new primality | |
Downloading template "new-template" to create project "primality" in primality/ ... | |
The following parameters were needed by the template but not provided: | |
author-email, author-name, category, copyright, github-username | |
You can provide them in /home/john/.stack/config.yaml, like this: | |
templates: | |
params: |
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
~ $ sudo apt-get install vim | |
Reading package lists... Done | |
Building dependency tree | |
Reading state information... Done | |
Suggested packages: | |
vim-doc vim-scripts | |
The following NEW packages will be installed: | |
vim | |
0 upgraded, 1 newly installed, 0 to remove and 316 not upgraded. | |
Need to get 0 B/976 kB of archives. |
NewerOlder