Skip to content

Instantly share code, notes, and snippets.

View billdozr's full-sized avatar

Alen Ribic billdozr

View GitHub Profile
cmdLnsParser ctype = (ctype++)
<$> (manyTill anyChar
(try (string ctype *> notFollowedBy alphaNum))
*> manyTill (noneOf "\n\r") eol)
<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)
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
attrParser = (,)
<$> option (oneOf "LMH" <*
(comma
<|> (eof *> return ""))
<?> "options: L|M|H")
<*> option (naturalOrFloat <* eof)
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) ++ ": "
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)
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)
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
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
(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))))