Skip to content

Commit

Permalink
Merge pull request #676 from input-output-hk/jonathanknowles/use-safe…
Browse files Browse the repository at this point in the history
…-library

Use `safe` library function `tailSafe` instead of locally-defined `tailOrEmpty`.
  • Loading branch information
Anviking committed Sep 4, 2019
2 parents c30010e + b0b64b1 commit f4054d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/jormungandr/cardano-wallet-jormungandr.cabal
Expand Up @@ -49,6 +49,7 @@ library
, http-client
, http-types
, memory
, safe
, servant
, servant-client
, servant-client-core
Expand Down
7 changes: 3 additions & 4 deletions lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs
Expand Up @@ -89,6 +89,8 @@ import Network.HTTP.Client
( Manager, defaultManagerSettings, newManager )
import Network.HTTP.Types.Status
( status400 )
import Safe
( tailSafe )
import Servant.API
( (:<|>) (..) )
import Servant.Client
Expand Down Expand Up @@ -141,7 +143,7 @@ mkNetworkLayer j = NetworkLayer
-- Get the descendants of the tip's /parent/.
-- The first descendant is therefore the current tip itself. We need to
-- skip it. Hence the 'tail'.
ids <- tailOrEmpty <$> getDescendantIds j (prevBlockHash tip) count
ids <- tailSafe <$> getDescendantIds j (prevBlockHash tip) count
`mappingError` \case
ErrGetDescendantsNetworkUnreachable e ->
ErrGetBlockNetworkUnreachable e
Expand All @@ -165,9 +167,6 @@ mkNetworkLayer j = NetworkLayer
where
mappingError = flip withExceptT

tailOrEmpty [] = []
tailOrEmpty (_:xs) = xs

{-------------------------------------------------------------------------------
Jormungandr Client
-------------------------------------------------------------------------------}
Expand Down
1 change: 1 addition & 0 deletions nix/.stack.nix/cardano-wallet-jormungandr.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f4054d0

Please sign in to comment.