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
| { mkDerivation, aeson, base, bytestring, directory, either | |
| , engine-io, engine-io-wai, http-types, js-jquery, lucid, random | |
| , servant, servant-client, servant-docs, servant-jquery | |
| , servant-lucid, servant-server, socket-io, stdenv, text, time | |
| , transformers, wai, wai-extra, warp | |
| }: | |
| mkDerivation { | |
| pname = "servant-examples"; | |
| version = "0.4.1"; | |
| src = ./.; |
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
| let | |
| pkgs = import <nixpkgs> {}; | |
| stdenv = pkgs.stdenv; | |
| haskellPackages = pkgs.haskell-ng.packages.ghc7101.override { | |
| overrides = self: super: { | |
| engine-io-wai = self.callPackage ~/Work/opensrc/engine.io/engine-io-wai {}; | |
| lumi-dashboard = self.callPackage ~/Work/lumi/lumi-dashboard {}; | |
| wai-cors = pkgs.haskell.lib.dontCheck pkgs.haskell.packages.ghc7101.wai-cors; | |
| }; | |
| }; |
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 OverloadedStrings #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| module Lib.Chat (eioServer, ServerState (..)) where | |
| import Prelude hiding (mapM_) | |
| import Control.Monad.IO.Class (liftIO) | |
| import Control.Monad.Trans.Reader | |
| import Data.Aeson ((.=)) |
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
| liftIO $ forkIO $ forever $ next cursor >>= \c -> do | |
| case c of | |
| Nothing -> undefined | |
| Just x -> do | |
| let u = resultToMaybe $ fromDatum x :: Maybe ChangeUser | |
| case u of | |
| Nothing -> undefined | |
| Just user -> SocketIO.emit "changes" (Changes user) |
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 OverloadedStrings #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| module Lib.Chat (eioServer, ServerState (..)) where | |
| import Prelude hiding (mapM_) | |
| import Control.Monad.IO.Class (liftIO) | |
| import Data.Aeson ((.=)) | |
| import Data.Foldable (mapM_) |
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
| cursor <- liftIO $ User.listRawChanges pool | |
| threadDelay 5000 $ do | |
| c <- next cursor | |
| case c of | |
| Nothing -> print "Nothing" | |
| Just x -> do | |
| let u = resultToMaybe $ fromDatum x :: Maybe [SecureUser] | |
| case u of | |
| Nothing -> print "Nothing" |
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 RankNTypes #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| import Servant hiding (Get, Post, Put, Delete, ReqBody) | |
| import qualified Servant as S | |
| import Data.Monoid ((<>)) | |
| import Data.Either.Unwrap (fromRight) | |
| import Data.Text (Text) |
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
| type API = | |
| Get ApiInfo | |
| :<|> "users" :> UsersAPI | |
| :<|> "socket.io" :> Raw | |
| serverT :: ServerT API AppIO | |
| serverT = do | |
| getApiInfo | |
| :<|> usersServer | |
| where |
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
| { nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7101" }: | |
| let | |
| inherit (nixpkgs) pkgs; | |
| f = { mkDerivation, aeson, attoparsec, attoparsec-enumerator | |
| , base, bytestring, conduit, conduit-extra, either, engine-io | |
| , http-types, monad-control, mtl, resourcet, rethinkdb | |
| , servant-server, socket-io, stdenv, stm, text, transformers |
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 OverloadedStrings #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| import Data.Monoid ((<>)) | |
| import Data.Aeson |