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.IO.Class (MonadIO) | |
import Control.Monad.IO.Class (liftIO) | |
import PureMVar | |
asyncGreet :: (MonadIO m) => MVarT m String | |
asyncGreet = do | |
v <- newMVar | |
fork $ do | |
let greeting = "Hello world" | |
liftIO $ putStrLn greeting |
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
LogEntry Nothing (Variable (Fresh 0)) [] | |
LogEntry Nothing (Spawn 0) [] | |
LogEntry (Just 0) (Variable (Write 0)) [BlockedOn Nothing 0] | |
LogEntry (Just 0) (Variable (Read 0)) [] | |
LogEntry (Just 0) Halt [BlockedOn Nothing 0] |
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
Failures: | |
1) blocking program should not block | |
predicate failed on: Nothing (after 3 tests): | |
nothing | |
Randomized with seed 308638565 | |
Finished in 0.0305 seconds | |
2 examples, 1 failure |
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
program :: MVarM () | |
program = do | |
chan <- newSkipChan :: MVarM (SkipChan Int) | |
fork $ void $ getSkipChan chan | |
mapM_ (putSkipChan chan) [0..10] | |
-- "new mvar" | |
-- "new mvar" | |
-- "write to mvar" | |
-- "fork" |
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
{-# LANGUAGE ExistentialQuantification #-} | |
import Control.Monad.Free | |
data MVar a = Empty | Val a | |
data MVarOps next = forall a. New (MVar a -> next) | |
| forall a. Put (MVar a) a next | |
| forall a. Take (MVar a) (a -> next) | |
-- GHC won't derive this for us :( |
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
module Foo where | |
import Control.Applicative | |
import Data.Set (Set) | |
import Data.Map (Map) | |
import qualified Data.Map as M | |
import qualified Data.Set as S | |
get :: String -> IO (Maybe String) | |
get = undefined |
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
module Main where | |
import Control.Monad.Eff | |
import Control.Reactive | |
import Debug.Trace | |
import Prelude | |
foreign import websocket | |
"function websocket(url) {\ | |
\ return function(outgoing) {\ |
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
from django.test import TestCase | |
from models import App | |
from my_api import api | |
class ResourceUriTestCase(TestCase): | |
urls = 'path.to.api.urls' | |
def test_uri_uses_the_uuid(self): | |
uuid = new_uuid() |
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
class MyResource(ModelResource): | |
def model_to_data(self, model, request=None): | |
bundle = self.build_bundle(obj=model, request=request) | |
return self.full_dehydrate(bundle).data | |
def resource_for_request(resource_name, filters, request): | |
resource = v1_dns_api.canonical_resource_for(resource_name) | |
objects = resource.get_object_list(request).filter(filters) | |
return (resource.model_to_data(model, request) for model in objects) |
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
from time import mktime | |
from django.utils.http import http_date, parse_http_date_safe | |
from tastypie.exceptions import ImmediateHttpResponse | |
from tastypie.http import HttpNotModified | |
class IfModifiedResource(ModelResource): | |
def cached_obj_get(self, request=None, **kwargs): | |
bundle = super(IfModifiedResource, self).cached_obj_get(request, **kwargs) |