sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.03k stars 94 forks source link

pair: integrate sanctuary-pair #557

Closed davidchambers closed 6 years ago

davidchambers commented 6 years ago

This pull request adds sanctuary-pair as a dependency, re-exports its functions, and updates several existing functions to use Pair a b rather than Array2 a b.

$ git show -U0 index.js | grep '//#'
+  //# PairType :: Type -> Type -> Type
+  //# Pair :: a -> b -> Pair a b
+  //# fst :: Pair a b -> a
+  //# snd :: Pair a b -> b
+  //# swap :: Pair a b -> Pair b a
-  //# unfoldr :: (b -> Maybe (Array2 a b)) -> b -> Array a
+  //# unfoldr :: (b -> Maybe (Pair a b)) -> b -> Array a
-  //# zip :: Array a -> Array b -> Array (Array2 a b)
+  //# zip :: Array a -> Array b -> Array (Pair a b)
-  //# pairs :: StrMap a -> Array (Array2 String a)
+  //# pairs :: StrMap a -> Array (Pair String a)
-  //# fromPairs :: Foldable f => f (Array2 String a) -> StrMap a
+  //# fromPairs :: Foldable f => f (Pair String a) -> StrMap a
sphvn commented 6 years ago

👍 This is nice

davidchambers commented 6 years ago

Are you planning to remove Array2 in a separate PR?

I'd been thinking it should remain in the default environment to allow S.I (['foo', 42]), but I'm open to hearing arguments in favour of disallowing such expressions by default.