SHARE
TWEET

Untitled

a guest Mar 21st, 2019 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-# Language RankNTypes, MultiParamTypeClasses #-}
  2. module Data.Nonempty where
  3.  
  4. import Data.Functor.Identity
  5.  
  6. import Control.FIFO.FIFO_r
  7. import Control.FIFO.FIFO
  8.  
  9. import Control.Unfoldable.Unfoldable_r
  10. import Control.Unfoldable.Unfoldable
  11.  
  12. import Control.Traversable.Traversable_r
  13. import Control.Traversable.Traversable
  14.  
  15. infixr 5 :|
  16.  
  17. data Nonempty a = a :| Nonempty a | End a deriving (Eq, Ord)
  18.  
  19.  
  20. instance Foldable0_r Identity Nonempty where
  21.  foldMap0_r = foldMap0_rDefault
  22.  
  23. --instance for (Linear_r Identity Nonempty)
  24. instance Get0_r Identity Nonempty where
  25.  get0_r = get0_rDefault
  26.  
  27. instance Unfoldable0_r Identity Nonempty
  28.  
  29. instance Set0_r Identity Nonempty where
  30.  set0_r = set0_rDefault
  31.  
  32. instance Stream_r Identity Nonempty
  33.  
  34. instance Foldable1_r Identity Nonempty where
  35.  foldMap1_r = foldMap1_rDefault
  36.  
  37. instance Get1_r Identity Nonempty where
  38.  get1_r (x :| xs) = (Identity x,Just xs)
  39.  get1_r (End x) = (Identity x,Nothing)
  40.  
  41. instance Unfoldable1_r Identity Nonempty where
  42.  unfoldr1_r = unfoldr1_rDefault
  43.  
  44. instance Set1_r Identity Nonempty where
  45.  set1_r (Identity x,Just xs) = (x :| xs)
  46.  set1_r (Identity x,Nothing) = (End x)
  47.  
  48. instance Traversable1_r Identity Nonempty where
  49.  traverse1_r = convert1_r
  50.  
  51. instance Linear_r Identity Nonempty
  52.  
  53. instance Functor_r Identity Nonempty where
  54.  fmap_r = fmap_rDefault
  55.  
  56. instance Foldable_r Identity Nonempty where
  57.  foldMap_r = foldMap_rDefault
  58.  
  59. instance Traversable_r Identity Nonempty where
  60.  traverse_r = traverse_rDefault'
  61.  
  62. --
  63.  
  64. instance Foldable0' Nonempty where
  65.  foldMap0' = foldMap0'Default
  66.  
  67. instance Get0 Nonempty where
  68.  
  69. instance Unfoldable0 Nonempty
  70.  
  71. instance Set0 Nonempty where
  72.  
  73. instance Stream Nonempty
  74.  
  75. instance Foldable1' Nonempty where
  76. foldMap1' = foldMap1'Default
  77.  
  78. instance Get1 Nonempty where
  79.  
  80. instance Unfoldable1 Nonempty where
  81. unfoldr1 = unfoldr1Default
  82.  
  83. instance Set1 Nonempty where
  84.  
  85. instance Traversable1' Nonempty where
  86.  traverse1' = convert1
  87.  
  88. instance Linear Nonempty
  89.  
  90. instance Functor' Nonempty where
  91.  fmap' = fmap'Default
  92.  
  93. instance Foldable' Nonempty where
  94. foldMap' = foldMap'Default
  95.  
  96. instance Traversable' Nonempty where
  97.  traverse' = traverse'Default'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top