From b1c2bfc8968e4f8f57e454906c6ac66135e5b82a Mon Sep 17 00:00:00 2001 From: Steve Dunham Date: Wed, 4 Mar 2026 19:09:32 -0800 Subject: [PATCH] Add Functor Either a --- src/Prelude.newt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Prelude.newt b/src/Prelude.newt index 0488c87..5b12249 100644 --- a/src/Prelude.newt +++ b/src/Prelude.newt @@ -304,8 +304,6 @@ pfunc arrayToList uses (Nil _::_) : ∀ a. Array a → List a := `(a,arr) => { return rval }` - - -- for now I'll run this in JS pfunc lines uses (arrayToList) : String → List String := `(s) => Prelude_arrayToList(null,s.split('\n'))` @@ -725,6 +723,10 @@ instance Bifunctor _×_ where instance Functor IO where map f a = bind a $ \ a => pure (f a) +instance ∀ a. Functor (Either a) where + map f (Left x) = Left x + map f (Right y) = Right (f y) + uncurry : ∀ a b c. (a → b → c) → (a × b) → c uncurry f (a,b) = f a b