Skip to content

Commit 7cdd6d7

Browse files
author
odr
committed
reduce js dependencies
1 parent 8a0e575 commit 7cdd6d7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

random-token.cabal

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ library
1717
, aeson
1818
, base64-bytestring
1919
, bytestring
20-
, cryptonite
2120
, deepseq
2221
, http-api-data
2322
, text
2423
if !(impl(ghcjs) || arch(javascript))
25-
build-depends: postgresql-simple
24+
build-depends: cryptonite
25+
, postgresql-simple
26+
,
2627
default-language: Haskell2010
2728
default-extensions: CPP
2829
, ConstraintKinds

src/Random/Token.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ module Random.Token
55
, tokenToText
66
, asciiToToken
77
, textToToken
8-
, generateToken
98
, unsafeCoerceToken
109
, tokenWithContents
10+
#ifndef ghcjs_HOST_OS
11+
, generateToken
12+
#endif
1113
) where
1214

1315
import Control.DeepSeq
@@ -22,9 +24,9 @@ import Data.Typeable
2224
import Test.QuickCheck.Arbitrary
2325
import Web.HttpApiData
2426

25-
import Crypto.Random as R
2627

2728
#ifndef ghcjs_HOST_OS
29+
import Crypto.Random as R
2830
import Database.PostgreSQL.Simple.FromField
2931
import Database.PostgreSQL.Simple.ToField
3032
#endif
@@ -54,11 +56,12 @@ instance forall a. (Typeable (Token a), Typeable a) => FromField (Token a) where
5456

5557
instance ToField (Token a) where
5658
toField = toField . tokenToText
57-
#endif
5859

5960
generateToken :: (MonadRandom m) => m (Token a)
6061
generateToken = Token <$> R.getRandomBytes 16
6162

63+
#endif
64+
6265
instance FromHttpApiData (Token a) where
6366
parseQueryParam = first T.pack . textToToken
6467

0 commit comments

Comments
 (0)