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
cmdLnsParser ctype = (ctype++) | |
<$> (manyTill anyChar | |
(try (string ctype *> notFollowedBy alphaNum)) | |
*> manyTill (noneOf "\n\r") eol) |
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
<interactive>:1:0: | |
Ambiguous type variable `a' in the constraint: | |
`TagParseable a' | |
arising from a use of `parseTagEntry' at <interactive>:1:0-81 | |
Probable fix: add a type signature that fixes these type variable(s) |
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 Text.Parsec hiding (many, optional, (<|>)) | |
import qualified Text.Parsec.Token as T | |
import qualified Text.Parsec.Language as L | |
import Control.Applicative | |
import Data.Char (isSpace) | |
import Maybe (isJust) | |
import Types | |
-- For efficiency, we will bind all the used lexical parsers at toplevel | |
lexer = T.makeTokenParser L.emptyDef |
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
attrParser = (,) | |
<$> option (oneOf "LMH" <* | |
(comma | |
<|> (eof *> return "")) | |
<?> "options: L|M|H") | |
<*> option (naturalOrFloat <* eof) |
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
data TodoEntry = TodoEntry { milestone :: (Maybe String) | |
, action :: String | |
, users :: (Maybe [String]) | |
, priority :: (Maybe Char) | |
, timeSpent :: (Maybe Double) | |
} deriving (Eq, Ord) | |
instance Show TodoEntry where | |
show entry = todoTagStr ++ (uStr $ users entry) ++ ": " |
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
lexer = T.makeTokenParser L.emptyDef | |
lexeme = T.lexeme lexer | |
parens = T.parens lexer | |
comma = T.comma lexer | |
colon = T.colon lexer | |
float = T.float lexer | |
symbol = T.symbol lexer | |
whiteSpace = T.whiteSpace lexer | |
-- Parser(s) |
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
parseMeta :: Parser (Maybe Char, Maybe Double) | |
parseMeta = do char '(' | |
priority <- optionMaybe (oneOf "HML") | |
timeSpent <- optionMaybe | |
(many (noneOf ")") >>= \sd -> | |
do return $ (read sd :: Double)) | |
char ')' | |
return (priority, timeSpent) |
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 Control.Monad.State | |
import System.Random | |
main = do randNums <- runTwoRandoms | |
putStrLn $ "Random two numbers: " ++ show randNums | |
type RandomState a = State StdGen a | |
getRandom :: Random a => RandomState a |
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
alen-ribics-macbook:~ alen$ sudo cabal install happstack | |
Resolving dependencies... | |
Downloading SMTPClient-1.0.2... | |
Configuring SMTPClient-1.0.2... | |
Preprocessing library SMTPClient-1.0.2... | |
Building SMTPClient-1.0.2... | |
[1 of 2] Compiling Network.SMTP.ClientSession ( Network/SMTP/ClientSession.hs, dist/build/Network/SMTP/ClientSession.o ) | |
[2 of 2] Compiling Network.SMTP.Client ( Network/SMTP/Client.hs, dist/build/Network/SMTP/Client.o ) | |
ar: creating archive dist/build/libHSSMTPClient-1.0.2.a | |
Installing library in /Users/alen/.cabal/lib/SMTPClient-1.0.2/ghc-6.10.4 |
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
(defmacro map->entity | |
[m entype] | |
`(apply ~(symbol (str "make-" entype)) | |
(interleave (keys ~m) (vals ~m)))) | |
(defmethod db-fetch ::hash-map | |
[repository key] | |
(let [result (db-query key (:db repository))] | |
(map->entity (second result) (first result)))) |