diff --git a/src/Data.Range.purs b/src/Data.Range.purs index a726f3c..3c02f65 100644 --- a/src/Data.Range.purs +++ b/src/Data.Range.purs @@ -15,6 +15,10 @@ data Bound a = BoundIncluding a | BoundExcluding a +instance Functor Bound where + map f (BoundIncluding a) = BoundIncluding $ f a + map f (BoundExcluding a) = BoundExcluding $ f a + derive instance Generic (Bound a) _ derive instance Ord a => Ord (Bound a) derive instance Eq a => Eq (Bound a) @@ -44,6 +48,11 @@ derive instance Eq a => Eq (Range a) instance Show a => Show (Range a) where show = genericShow +instance Functor Range where + map f (RangeAbove b) = RangeAbove $ map f b + map f (RangeBelow b) = RangeBelow $ map f b + map f (RangeBetween a b) = RangeBetween (map f a) (map f b) + instance Semigroup (Range a) where append (RangeAbove a) (RangeBelow b) = RangeBetween a b append (RangeBelow a) (RangeAbove b) = RangeBetween a b