Skip to content

Commit

Permalink
Adding a Traversable instance for Cursor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Jenkins authored and krisajenkins committed Jan 14, 2021
1 parent 7b70563 commit 202bfe0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web-common/src/Cursor.purs
Expand Up @@ -31,9 +31,10 @@ import Data.Lens (Traversal', wander)
import Data.Lens.Index (class Index)
import Data.Maybe (Maybe, fromMaybe, maybe)
import Data.Ord as Ord
import Data.Traversable (class Traversable, sequenceDefault, traverse)
import Foreign (ForeignError(..), fail, readArray, readInt)
import Foreign.Class (class Decode, class Encode, decode, encode)
import Prelude (class Eq, class Functor, class Ord, class Show, bind, map, otherwise, pure, show, (#), ($), (+), (-), (<<<), (<>), (>=), (>>>))
import Prelude (class Eq, class Functor, class Ord, class Show, bind, map, otherwise, pure, show, (#), ($), (+), (-), (<$>), (<<<), (<>), (>=), (>>>))
import Test.QuickCheck.Arbitrary (class Arbitrary, arbitrary)
import Test.QuickCheck.Gen (arrayOf)

Expand All @@ -53,6 +54,10 @@ instance foldableCursor :: Foldable Cursor where
foldl f acc (Cursor _ xs) = foldl f acc xs
foldMap f (Cursor _ xs) = foldMap f xs

instance traversableCursor :: Traversable Cursor where
traverse f (Cursor n xs) = Cursor n <$> traverse f xs
sequence = sequenceDefault

instance showCursor :: Show a => Show (Cursor a) where
show (Cursor index xs) = "Cursor " <> show index <> " " <> show xs

Expand Down

0 comments on commit 202bfe0

Please sign in to comment.