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

Fix warnings generated by purescript-0.8.0 #36

Closed
wants to merge 2 commits into from
Closed
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
12 changes: 6 additions & 6 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"package.json"
],
"dependencies": {
"purescript-arrays": "^0.4.0",
"purescript-either": "^0.2.0",
"purescript-foldable-traversable": "^0.4.0",
"purescript-functions": "^0.1.0",
"purescript-integers": "^0.2.0",
"purescript-arrays": "^1.0.0-rc.1",
"purescript-either": "^1.0.0-rc.1",
"purescript-foldable-traversable": "^1.0.0-rc.1",
"purescript-functions": "^1.0.0-rc.1",
"purescript-integers": "^1.0.0-rc.1",
"purescript-strings": "^0.7.0"
},
"devDependencies": {
"purescript-console": "^0.1.0"
"purescript-console": "^1.0.0-rc.1"
}
}
15 changes: 7 additions & 8 deletions src/Data/Foreign.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ module Data.Foreign
, readArray
) where

import Prelude
import Prelude (class Eq, class Show, pure, ($), const, (<<<), (==), (&&), append, show)

import Data.Either (Either(..), either)
import Data.Maybe (maybe)
import Data.Function (Fn3(), runFn3)
import Data.Int ()
import qualified Data.Int as Int
import Data.Function.Uncurried (Fn3(), runFn3)
import Data.Int as Int
import Data.String (toChar)

-- | A type for _foreign data_.
Expand All @@ -51,10 +50,10 @@ data ForeignError
| JSONError String

instance showForeignError :: Show ForeignError where
show (TypeMismatch exp act) = "Type mismatch: expected " ++ exp ++ ", found " ++ act
show (ErrorAtIndex i e) = "Error at array index " ++ show i ++ ": " ++ show e
show (ErrorAtProperty prop e) = "Error at property " ++ show prop ++ ": " ++ show e
show (JSONError s) = "JSON error: " ++ s
show (TypeMismatch exp act) = "Type mismatch: expected " `append` exp `append` ", found " `append` act
show (ErrorAtIndex i e) = "Error at array index " `append` show i `append` ": " `append` show e
show (ErrorAtProperty prop e) = "Error at property " `append` show prop `append` ": " `append` show e
show (JSONError s) = "JSON error: " `append` s

instance eqForeignError :: Eq ForeignError where
eq (TypeMismatch a b) (TypeMismatch a' b') = a == a' && b == b'
Expand Down
17 changes: 8 additions & 9 deletions src/Data/Foreign/Class.purs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
-- | This module defines a type class for reading foreign values.

module Data.Foreign.Class
( IsForeign
( class IsForeign
, read
, readJSON
, readWith
, readProp
) where

import Prelude
import Prelude ((>>=), (<<<), zero, pure)

import Data.Array (range, zipWith, length)
import Data.Either (Either(..), either)
import Data.Foreign
import Data.Foreign.Index
import Data.Foreign.Null
import Data.Foreign.NullOrUndefined
import Data.Foreign.Undefined
import Data.Int ()
import Data.Foreign (F, Foreign, ForeignError(ErrorAtIndex), parseJSON, readArray, readInt, readNumber, readBoolean, readChar, readString)
import Data.Foreign.Index (class Index, errorAt, (!))
import Data.Foreign.Null (Null, readNull)
import Data.Foreign.NullOrUndefined (NullOrUndefined, readNullOrUndefined)
import Data.Foreign.Undefined (Undefined, readUndefined)
import Data.Traversable (sequence)

-- | A type class instance for this class can be written for a type if it
Expand All @@ -30,7 +29,7 @@ class IsForeign a where
read :: Foreign -> F a

instance foreignIsForeign :: IsForeign Foreign where
read f = return f
read f = pure f

instance stringIsForeign :: IsForeign String where
read = readString
Expand Down
14 changes: 5 additions & 9 deletions src/Data/Foreign/Index.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- | _property indices_.

module Data.Foreign.Index
( Index
( class Index
, prop
, index
, ix, (!)
Expand All @@ -11,12 +11,11 @@ module Data.Foreign.Index
, errorAt
) where

import Prelude
import Prelude (flip, (==), (||), pure)

import Data.Either (Either(..))
import Data.Foreign
import Data.Function (Fn2(), runFn2, Fn4(), runFn4)
import Data.Int ()
import Data.Foreign (Foreign, F, ForeignError(ErrorAtIndex, ErrorAtProperty, TypeMismatch), typeOf, isUndefined, isNull)
import Data.Function.Uncurried (Fn2(), runFn2, Fn4(), runFn4)

-- | This type class identifies types wich act like _property indices_.
-- |
Expand All @@ -27,11 +26,8 @@ class Index i where
hasOwnProperty :: i -> Foreign -> Boolean
errorAt :: i -> ForeignError -> ForeignError

infixl 9 !

-- | An infix alias for `ix`.
(!) :: forall i. (Index i) => Foreign -> i -> F Foreign
(!) = ix
infixl 9 ix as !

foreign import unsafeReadPropImpl :: forall r k. Fn4 r (Foreign -> r) k Foreign (F Foreign)

Expand Down
4 changes: 2 additions & 2 deletions src/Data/Foreign/Keys.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module Data.Foreign.Keys
( keys
) where

import Prelude
import Prelude (($), (==))

import Data.Either (Either(..))
import Data.Foreign
import Data.Foreign (F, Foreign, ForeignError(TypeMismatch), typeOf, isUndefined, isNull)

foreign import unsafeKeys :: Foreign -> Array String

Expand Down
4 changes: 2 additions & 2 deletions src/Data/Foreign/Null.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Data.Foreign.Null
, readNull
) where

import Prelude
import Prelude ((<$>), (<<<), pure)

import Data.Maybe (Maybe(..))
import Data.Foreign
import Data.Foreign (F, Foreign, isNull)

-- | A `newtype` wrapper whose `IsForeign` instance correctly handles
-- | null values.
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Foreign/NullOrUndefined.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Data.Foreign.NullOrUndefined
, readNullOrUndefined
) where

import Prelude
import Prelude ((<$>), (<<<), pure, (||))

import Data.Maybe (Maybe(..))
import Data.Foreign
import Data.Foreign (F, Foreign, isUndefined, isNull)

-- | A `newtype` wrapper whose `IsForeign` instance correctly handles
-- | null and undefined values.
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Foreign/Undefined.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Data.Foreign.Undefined
, readUndefined
) where

import Prelude
import Prelude ((<$>), (<<<), pure)

import Data.Maybe (Maybe(..))
import Data.Foreign
import Data.Foreign (F, Foreign, isUndefined)

-- | A `newtype` wrapper whose `IsForeign` instance correctly handles
-- | undefined values.
Expand Down