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
-- combinator that returns a mismatch if the method doesn't match | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
module Servant.Method 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
type ModelAPI = | |
"models" :> | |
( ProjectKey :> Get '[JSON] [Model] | |
:<|> ProjectKey :> MultipartUpload :> Post '[JSON] Model | |
:<|> ProjectKey :> Capture "modelId" ID :> Get '[JSON] Model | |
:<|> ProjectKey :> Capture "modelId" ID :> "predictions" :> ReqBody '[JSON] PredictionInput :> Post '[JSON] Prediction | |
:<|> ProjectKey :> Capture "modelId" ID :> "predictions" :> Get '[JSON] [Prediction] | |
:<|> ProjectKey :> Capture "modelId" ID :> "predictions" :> Capture "predictionId" ID :> Get '[JSON] Prediction | |
) |
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
-- First, I made it application specific | |
attemptConnect :: Int -> TWInfo -> Manager -> APIRequest apiName responseType -> ResourceT IO (ResumableSource (ResourceT IO) StreamingAPI) | |
attemptConnect delay twInfo mgr = do | |
ms <- streamShowStatus twInfo mgr (statusesFilter accountName [accountID]) | |
case ms of | |
Just s -> return s | |
Nothing -> do | |
liftIO $ putStrLn ("FAILED, delaying for " <> show delay <> "s") | |
liftIO $ threadDelay (delay * 1000 * 1000) | |
attemptConnect (delay*2) twInfo mgr |
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 Effects exposing (Effects, Never) | |
import Html exposing (Html) | |
import Signal exposing (Signal, Mailbox, Address) | |
import Signal.Extra exposing (foldp', combine, mapMany) | |
import Task | |
import StartApp exposing (Config, App) | |
import Debug |
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 DataKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module Proxy 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
import Html exposing (div, button, text, Html, p, h1, span, pre) | |
import Html.Attributes exposing (style) | |
import Html.Events exposing (onClick) | |
import StartApp.Simple as StartApp | |
import Signal exposing (Address) | |
import Tangle | |
type alias Model = | |
{ tangle : Tangle.Model |
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 ParentView extends React.Component { | |
constructor() { | |
this.state = { | |
// parent state becomes child props | |
items: ["one", "two", "three"] | |
} | |
} | |
// item is a complete domain object with enough info to do things with | |
onDeleteItem(item) { |
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 Action | |
= Update String | |
| Enter | |
type alias Model = { text : String } | |
update : Action -> Model -> Model | |
update action model | |
case action of | |
Update txt -> { model | text <- txt } |
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 Prelude hiding (lookup) | |
import System.IO | |
import Data.Char | |
import Data.List as List hiding (lookup) | |
import qualified Data.List.Split as List | |
import Debug.Trace | |
import Control.Monad | |
import Data.Maybe |
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
main = do | |
foo <- getLine | |
return () | |
-- the type of `getLine` is IO String, but how can we figure that out? | |
-- let's put the wrong type inline and let GHC yell at us | |
-- "Couldn't match expected type ‘()’ with actual type ‘IO String’" | |
main2 = do | |
-- we're checking the type of getLine here |