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
package main | |
import "fmt" | |
type Lx func(int) int | |
type Fx func(int) Lx | |
type Mx func(int) Fx | |
func cmbSum(a int, b int) Mx { | |
return func(c int) Fx { |
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
verify j = case J.verify (J.secret $ pack "secret-key") =<< J.decode j of | |
Nothing -> return Nothing | |
Just j -> do | |
r <- expired j | |
case r of | |
Just True -> return $ Just j | |
_ -> return Nothing |
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
create d t = do | |
r <- runDB $ t R.# R.insert (R.toDatum d) | |
return . maybeHelper $ insertKey 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
import System.Random | |
-- takes a random generator and returns a list of strings of 50 chars | |
start_population :: (RandomGen g) => g -> [[Char]] | |
start_population gen = | |
[take 50 $ randomRs ('A', 'z') gen | x <- [0..]] | |
main = do | |
randomGen <- newStdGen -- get a random generator | |
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
instance ToDatum (Ratio Integer) where | |
toDatum a = toDatum (parseRational a) | |
parseRational :: Rational -> Double | |
parseRational = fromRational |
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
-- Looks like run h $ line [[1,2],[3,4],[5,6]] :: IO Line was not matching on Array v so was falling to mempty | |
-- This solution return (in Show form) fromList [LonLat 1 2,LonLat 3 4,LonLat 5 6] | |
instance FromDatum a => FromDatum (Vector a) where | |
parseDatum (Array v) = fmap V.fromList . mapM parseDatum $ V.toList v | |
parseDatum (Line l) = fmap V.fromList . mapM (parseDatum . toDatum) $ V.toList l | |
parseDatum _ = mempty |
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
### Failure in ./Database/RethinkDB/Functions.hs:409: expression `run' h $ table "posts" # group (!"author") (reduce (\a b -> a + "\n" + b) . R.map (!"message"))' | |
expected: [{"group":"bill","reduction":"hi\nhello"},{"group":"bob","reduction":"lorem ipsum"}] | |
but got: [{"group":"bill","reduction":"hello\nhi"},{"group":"bob","reduction":"lorem ipsum"}] |
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
diff --git a/Database/RethinkDB/Network.hs b/Database/RethinkDB/Network.hs | |
index 74cb1d9..feec063 100644 | |
--- a/Database/RethinkDB/Network.hs | |
+++ b/Database/RethinkDB/Network.hs | |
@@ -28,10 +28,10 @@ import Control.Monad (when, forever, forM_) | |
import Data.Typeable (Typeable) | |
import Network (HostName) | |
import Network.Socket ( | |
- socket, Family(AF_INET), SocketType(Stream), sClose, SockAddr(SockAddrInet), setSocketOption, SocketOption(NoDelay), | |
- Socket) |
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
instance FromDatum a => Result (Cursor a) where | |
convertResult r = do | |
(v, _) <- convertResult r | |
(_, p) <- responseProfile v | |
c <- makeCursor r | |
return (c { cursorMap = unsafeFromDatum }, p) |
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
weak <- mkWeakPtr mbox $ Just $ do | |
closeToken h tok -- TODO: don't close if already closed | |
atomicModifyIORef' (rdbWait h) $ \mboxes -> | |
(M.delete tok mboxes, ()) |
OlderNewer