From aa1fc6731d37b75083039dc80720761b94fe9607 Mon Sep 17 00:00:00 2001 From: Denis Stoyanov Date: Tue, 31 Jul 2018 15:55:26 +0300 Subject: [PATCH 1/2] fix alt for ZipList --- src/Data/List/ZipList.purs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Data/List/ZipList.purs b/src/Data/List/ZipList.purs index 920be44..b53388f 100644 --- a/src/Data/List/ZipList.purs +++ b/src/Data/List/ZipList.purs @@ -6,15 +6,16 @@ module Data.List.ZipList ) where import Prelude -import Prim.TypeError (class Fail, Text) + import Control.Alt (class Alt) import Control.Alternative (class Alternative) import Control.Plus (class Plus) import Data.Foldable (class Foldable) -import Data.List.Lazy (List, repeat, zipWith) +import Data.List.Lazy (List, drop, length, repeat, zipWith) import Data.Newtype (class Newtype) import Data.Traversable (class Traversable) import Partial.Unsafe (unsafeCrashWith) +import Prim.TypeError (class Fail, Text) -- | `ZipList` is a newtype around `List` which provides a zippy -- | `Applicative` instance. @@ -46,7 +47,7 @@ instance applicativeZipList :: Applicative ZipList where pure = ZipList <<< repeat instance altZipList :: Alt ZipList where - alt = append + alt (ZipList xs) (ZipList ys) = ZipList $ (xs <> drop (length xs) ys) instance plusZipList :: Plus ZipList where empty = mempty From eca6ea05e26dc23c4cea93ef38b5bb792e4a9fba Mon Sep 17 00:00:00 2001 From: Denis Stoyanov Date: Wed, 1 Aug 2018 01:03:49 +0300 Subject: [PATCH 2/2] remove redundant $ --- src/Data/List/ZipList.purs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/List/ZipList.purs b/src/Data/List/ZipList.purs index b53388f..09e334d 100644 --- a/src/Data/List/ZipList.purs +++ b/src/Data/List/ZipList.purs @@ -47,7 +47,7 @@ instance applicativeZipList :: Applicative ZipList where pure = ZipList <<< repeat instance altZipList :: Alt ZipList where - alt (ZipList xs) (ZipList ys) = ZipList $ (xs <> drop (length xs) ys) + alt (ZipList xs) (ZipList ys) = ZipList $ xs <> drop (length xs) ys instance plusZipList :: Plus ZipList where empty = mempty