Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it work with psc-0.9.1 #12

Merged
merged 3 commits into from
Jul 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
node_js:
- 5.6
install:
- npm install purescript@0.8.5 bower pulp@8.2.1 purescript-psa -g
- npm install purescript@0.9.1 bower pulp@9.0.1 purescript-psa -g
- bower install
script:
- pulp build --censor-lib && pulp docs
Expand Down
12 changes: 6 additions & 6 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"purescript"
],
"dependencies": {
"purescript-generics": "~0.7.0",
"purescript-eff": "~0.1.2",
"purescript-var": "~0.1.0",
"purescript-dom": "~0.2.9",
"purescript-exceptions": "^0.3.4"
"purescript-generics": "~1.0.0",
"purescript-eff": "~1.0.0",
"purescript-var": "~0.2.0",
"purescript-dom": "~1.1.0",
"purescript-exceptions": "^1.0.0"
},
"devDependencies": {
"purescript-console": "~0.1.0"
"purescript-console": "~1.0.0"
}
}
44 changes: 22 additions & 22 deletions src/WebSocket.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,24 @@ module WebSocket
, BinaryType(..)
) where

import Prelude (class Ord, compare, class Eq, eq, class Bounded, class Show,
Unit, (<$>), map, (<<<), ($))

import Control.Monad.Eff (Eff())
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION)
import Control.Monad.Eff.Var (Var(), GettableVar(), SettableVar(), makeVar,
makeGettableVar, makeSettableVar)
import Data.Function (runFn2, Fn2())
import Data.Functor.Invariant (imap)
import Data.Functor.Contravariant (cmap)
import DOM.Event.EventTarget (eventListener, EventListener())
import DOM.Event.Types (Event(), MessageEvent(), CloseEvent())
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Generic (class Generic, gShow, gEq, gCompare)
import Data.Enum (class Enum, defaultSucc, defaultPred, toEnum, Cardinality(..))
import Unsafe.Coerce (unsafeCoerce)
import Control.Monad.Eff.Var (Var, GettableVar, SettableVar, makeVar, makeGettableVar, makeSettableVar)
import DOM.Event.EventTarget (eventListener, EventListener)
import DOM.Event.Types (Event)
import DOM.Websocket.Event.Types (CloseEvent, MessageEvent)
import Data.Either (Either(..))
import Data.Enum (class BoundedEnum, class Enum, defaultSucc, defaultPred, toEnum, Cardinality(..))
import Data.Foreign (toForeign, unsafeFromForeign)
import Data.Foreign.Index (prop)
import Data.Nullable (toNullable, Nullable())
import Data.Function.Uncurried (runFn2, Fn2)
import Data.Functor.Contravariant (cmap)
import Data.Functor.Invariant (imap)
import Data.Generic (class Generic, gShow, gEq, gCompare)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Nullable (toNullable, Nullable)
import Prelude (class Ord, compare, class Eq, eq, class Bounded, class Show, Unit, (<$>), map, (<<<), ($))
import Unsafe.Coerce (unsafeCoerce)

foreign import specViolation :: forall a. String -> a

Expand Down Expand Up @@ -99,13 +97,13 @@ coerceEvent :: forall a. Event -> a
coerceEvent = unsafeCoerce

enhanceConnection :: ConnectionImpl -> Connection
enhanceConnection c = Connection
enhanceConnection c = Connection $
{ binaryType: imap toBinaryType fromBinaryType $ makeVar c.getBinaryType c.setBinaryType
, bufferedAmount: makeGettableVar c.getBufferedAmount
, onclose: cmap (eventListener <<< (`map` coerceEvent)) (makeSettableVar c.setOnclose)
, onerror: cmap (eventListener <<< (`map` coerceEvent)) (makeSettableVar c.setOnerror)
, onmessage: cmap (eventListener <<< (`map` coerceEvent)) (makeSettableVar c.setOnmessage)
, onopen: cmap (eventListener <<< (`map` coerceEvent)) (makeSettableVar c.setOnopen)
, onclose: cmap (eventListener <<< (_ `map` coerceEvent)) (makeSettableVar c.setOnclose)
, onerror: cmap (eventListener <<< (_ `map` coerceEvent)) (makeSettableVar c.setOnerror)
, onmessage: cmap (eventListener <<< (_ `map` coerceEvent)) (makeSettableVar c.setOnmessage)
, onopen: cmap (eventListener <<< (_ `map` coerceEvent)) (makeSettableVar c.setOnopen)
, protocol: makeVar c.getProtocol c.setProtocol
, readyState: unsafeReadyState <$> makeGettableVar c.getReadyState
, url: makeGettableVar c.getUrl
Expand Down Expand Up @@ -214,10 +212,12 @@ instance boundedReadyState :: Bounded ReadyState where
bottom = Connecting
top = Closed

instance enumReadyState :: Enum ReadyState where
instance boundedEnumReadyState :: BoundedEnum ReadyState where
cardinality = Cardinality 4
toEnum = toEnumReadyState
fromEnum = fromEnumReadyState

instance enumReadyState :: Enum ReadyState where
succ = defaultSucc toEnumReadyState fromEnumReadyState
pred = defaultPred toEnumReadyState fromEnumReadyState

Expand Down