git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Added some missing function instances.
2863bddjoneshf
examples/passing/TypeClasses.purs−14
@@ -57,20 +57,6 @@ test4 = \_ -> return 1
57
57
58test5 = \_ -> Just 1 >>= \n -> return (n + 1)
58test5 = \_ -> Just 1 >>= \n -> return (n + 1)
59
59
60−instance functorFunction :: Functor ((->) r) where
61− (<$>) = liftM1
62−
63−instance applyFunction :: Apply ((->) r) where
64− (<*>) = ap
65−
66−instance applicativeFunction :: Applicative ((->) r) where
67− pure a _ = a
68−
69−instance bindFunction :: Bind ((->) r) where
70− (>>=) f g r = g (f r) r
71−
72−instance monadFunction :: Monad ((->) r)
73−
74ask r = r
60ask r = r
75
61
76runReader r f = f r
62runReader r f = f r
prelude/prelude.purs+17
@@ -154,6 +154,20 @@ module Prelude
154 a' <- a
154 a' <- a
155 return (f' a')
155 return (f' a')
156
156
157+ instance functorArr :: Functor ((->) r) where
158+ (<$>) = (<<<)
159+
160+ instance applyArr :: Apply ((->) r) where
161+ (<*>) f g x = f x (g x)
162+
163+ instance applicativeArr :: Applicative ((->) r) where
164+ pure = const
165+
166+ instance bindArr :: Bind ((->) r) where
167+ (>>=) m f x = f (m x) x
168+
169+ instance monadArr :: Monad ((->) r)
170+
157 infixl 7 *
171 infixl 7 *
158 infixl 7 /
172 infixl 7 /
159 infixl 7 %
173 infixl 7 %
@@ -443,6 +457,9 @@ module Prelude
443 instance semigroupString :: Semigroup String where
457 instance semigroupString :: Semigroup String where
444 (<>) = concatString
458 (<>) = concatString
445
459
460+ instance semigroupArr :: (Semigroup s') => Semigroup (s -> s') where
461+ (<>) f g = \x -> f x <> g x
462+
446 infixr 5 ++
463 infixr 5 ++
447
464
448 (++) :: forall s. (Semigroup s) => s -> s -> s
465 (++) :: forall s. (Semigroup s) => s -> s -> s