Skip to content

Deduplicate testing code - with records #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more patching, about to implement remaining tests
  • Loading branch information
milesfrain committed May 19, 2021
commit f34b041a11f5b9a3cc7d375916c0476f18a6a457
10 changes: 10 additions & 0 deletions src/Data/List/Lazy.purs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ module Data.List.Lazy
, snoc'
, manyRec

, replicate1
, replicate1M

) where

import Prelude
Expand Down Expand Up @@ -155,6 +158,13 @@ snoc' _ _ = unsafeCrashWith "todo snoc' for Lazy List"
manyRec :: forall f a. MonadRec f => Alternative f => f a -> f (List a)
manyRec _ = unsafeCrashWith "todo manyRec for Lazy List"

-- Specialized from Unfoldable1's replicate1 / replicate1A
replicate1 :: forall a. Int -> a -> List a
replicate1 _ _ = unsafeCrashWith "todo replicate1 for Lazy List"

replicate1M :: forall m a. Monad m => Int -> m a -> m (List a)
replicate1M _ _ = unsafeCrashWith "todo replicate1M for Lazy List"

-- | Convert a list into any unfoldable structure.
-- |
-- | Running time: `O(n)`
Expand Down
10 changes: 10 additions & 0 deletions src/Data/List/Lazy/NonEmpty.purs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ module Data.List.Lazy.NonEmpty
, foldrLazy
, scanlLazy

, replicate1
, replicate1M

) where

import Prelude
Expand Down Expand Up @@ -276,6 +279,13 @@ foldrLazy _ _ _ = unsafeCrashWith "todo foldrLazy for LazyNonEmptyList"
scanlLazy :: forall a b. (b -> a -> b) -> b -> NonEmptyList a -> NonEmptyList b
scanlLazy _ _ _ = unsafeCrashWith "todo scanlLazy for LazyNonEmptyList"

-- Specialized from Unfoldable1's replicate1 / replicate1A
replicate1 :: forall a. Int -> a -> NonEmptyList a
replicate1 _ _ = unsafeCrashWith "todo replicate1 for LazyNonEmptyList"

replicate1M :: forall m a. Monad m => Int -> m a -> m (NonEmptyList a)
replicate1M _ _ = unsafeCrashWith "todo replicate1M for LazyNonEmptyList"

-----------

toUnfoldable :: forall f. Unfoldable f => NonEmptyList ~> f
Expand Down
41 changes: 39 additions & 2 deletions test/Test/API.purs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,45 @@ type OnlyLazy c =
, cycle :: forall a. c a -> c a
, foldrLazy :: forall a b. Lazy b => (a -> b -> b) -> b -> c a -> b
, scanlLazy :: forall a b. (b -> a -> b) -> b -> c a -> c b

-- Specialized from Unfoldable1's replicate1 / replicate1A
, replicate1 :: forall a. Int -> a -> c a
, replicate1M :: forall m a. Monad m => Int -> m a -> m (c a)
}


-- Non Overlapping APIs

type OnlyStrictCanEmpty :: forall k. (k -> Type) -> Type
type OnlyStrictCanEmpty c =
{
-- Same names, but different APIs
deleteAt :: forall a. Int -> c a -> Maybe (c a)
}

type OnlyStrictNonEmpty :: forall k. (k -> Type) -> (k -> Type) -> Type
type OnlyStrictNonEmpty c canEmpty =
{
-- Same names, but different APIs
deleteAt :: forall a. Int -> c a -> Maybe (canEmpty a)
}

-- Todo - investigate why kind signature is only recommended when
-- records contain only a single field

type OnlyLazyCanEmpty c =
{
-- Same names, but different APIs
deleteAt :: forall a. Int -> c a -> c a
-- Unique functions
-- Specialized from Unfoldable's replicate / replicateA
, replicate :: forall a. Int -> a -> c a
, replicateM :: forall m a. Monad m => Int -> m a -> m (c a)
}

-- Todo - no overlap
-- Or may not be necessary to define here
type OnlyLazyNonEmpty :: forall k. (k -> Type) -> (k -> Type) -> Type
type OnlyLazyNonEmpty c canEmpty =
{
-- Same names, but different APIs
deleteAt :: forall a. Int -> c a -> canEmpty a
}
Loading