This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Data.NonEmptyArray where | |
import Prelude | |
data NonEmpty a = | |
NonEmpty a (Array a) | |
instance showNonEmpty :: Show a => Show (NonEmpty a) where | |
show (NonEmpty a as) = "NonEmpty: " <> show a <> show as | |
instance eqNonEmpty :: Eq a => Eq (NonEmpty a) where | |
eq (NonEmpty a as) (NonEmpty b bs) | a == b && as == bs = true | |
eq _ _ = false | |
instance semigroupNonEmpty :: Semigroup (NonEmpty a) where | |
append (NonEmpty a as) (NonEmpty b bs) = NonEmpty a (as <> [ b ] <> bs) | |
instance functorNonEmpty :: Functor NonEmpty where | |
map f (NonEmpty a as) = NonEmpty (f a) (map f as) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment