From c595a8e01f729a80010bba9f1bd55e3d878068fb Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Tue, 18 Mar 2014 17:35:11 +0400 Subject: Add instance Default TrackerList --- src/Network/BitTorrent/Tracker/List.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Network/BitTorrent/Tracker/List.hs') diff --git a/src/Network/BitTorrent/Tracker/List.hs b/src/Network/BitTorrent/Tracker/List.hs index f2a4b264..5ab43c86 100644 --- a/src/Network/BitTorrent/Tracker/List.hs +++ b/src/Network/BitTorrent/Tracker/List.hs @@ -9,6 +9,7 @@ -- -- For more info see: -- +{-# LANGUAGE FlexibleInstances #-} module Network.BitTorrent.Tracker.List ( -- * Tracker list TrackerList @@ -25,6 +26,7 @@ module Network.BitTorrent.Tracker.List import Prelude hiding (mapM, foldr) import Control.Applicative import Control.Exception +import Data.Default import Data.List as L (elem, any, filter, null) import Data.Maybe import Data.Foldable @@ -49,6 +51,10 @@ data TrackerList a | TierList [Tier a] -- ^ torrent file 'announce-list' field only deriving (Show, Eq) +-- | Empty tracker list. Can be used for trackerless torrents. +instance Default (TrackerList URI) where + def = TierList [] + instance Functor TrackerList where fmap f (Announce a) = Announce (f a) fmap f (TierList a) = TierList (fmap (fmap f) a) -- cgit v1.2.3