summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-14 19:52:03 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-14 19:52:03 +0400
commit780cfe4fc3b59f76b23ec18d8e798d300e9a7e7e (patch)
tree2243a48b5bb8a21ff8d847709b88e1254aabb209
parent04d5e90177f9edbc49c5392f471950ebd0bfea4c (diff)
Override default fixity for Get operators
-rw-r--r--src/Data/BEncode.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs
index d1d153b..8768dac 100644
--- a/src/Data/BEncode.hs
+++ b/src/Data/BEncode.hs
@@ -683,21 +683,29 @@ field m = Get $ do
683f <$>! k = f <$> field (req k) 683f <$>! k = f <$> field (req k)
684{-# INLINE (<$>!) #-} 684{-# INLINE (<$>!) #-}
685 685
686infixl 4 <$>!
687
686-- | Shorthand for /f <$> optional (field (req k))/. 688-- | Shorthand for /f <$> optional (field (req k))/.
687(<$>?) :: BEncode a => (Maybe a -> b) -> BKey -> Get b 689(<$>?) :: BEncode a => (Maybe a -> b) -> BKey -> Get b
688f <$>? k = f <$> optional (field (req k)) 690f <$>? k = f <$> optional (field (req k))
689{-# INLINE (<$>?) #-} 691{-# INLINE (<$>?) #-}
690 692
693infixl 4 <$>?
694
691-- | Shorthand for /f <*> field (req k)/. 695-- | Shorthand for /f <*> field (req k)/.
692(<*>!) :: BEncode a => Get (a -> b) -> BKey -> Get b 696(<*>!) :: BEncode a => Get (a -> b) -> BKey -> Get b
693f <*>! k = f <*> field (req k) 697f <*>! k = f <*> field (req k)
694{-# INLINE (<*>!) #-} 698{-# INLINE (<*>!) #-}
695 699
700infixl 4 <*>!
701
696-- | Shorthand for /f <*> optional (field (req k))/. 702-- | Shorthand for /f <*> optional (field (req k))/.
697(<*>?) :: BEncode a => Get (Maybe a -> b) -> BKey -> Get b 703(<*>?) :: BEncode a => Get (Maybe a -> b) -> BKey -> Get b
698f <*>? k = f <*> optional (field (req k)) 704f <*>? k = f <*> optional (field (req k))
699{-# INLINE (<*>?) #-} 705{-# INLINE (<*>?) #-}
700 706
707infixl 4 <*>?
708
701-- | Run a 'Get' monad. 709-- | Run a 'Get' monad.
702fromDict :: forall a. Typeable a => Get a -> BValue -> Result a 710fromDict :: forall a. Typeable a => Get a -> BValue -> Result a
703fromDict m (BDict d) = evalStateT (runGet m) d 711fromDict m (BDict d) = evalStateT (runGet m) d