WTF

Nov. 19th, 2011 05:58 pm
deniok: (Default)
[personal profile] deniok
из Control.Applicative (с) Conor McBride and Ross Paterson 2005
newtype Const a b = Const { getConst :: a }

instance Functor (Const m) where
    fmap _ (Const v) = Const v

instance Monoid m => Applicative (Const m) where
    pure _ = Const mempty
    Const f <*> Const v = Const (f `mappend` v)


из Data.Functor.Constant (c) Ross Paterson 2010
(transformers package)
import Control.Applicative -- Sic!

...

newtype Constant a b = Constant { getConstant :: a }

instance Functor (Constant a) where
    fmap f (Constant x) = Constant x

...

instance (Monoid a) => Applicative (Constant a) where
    pure _ = Constant mempty
    Constant x <*> Constant y = Constant (x `mappend` y)


UPD. Росс ответил в кафе, что it was an accident
This account has disabled anonymous posting.
If you don't have an account you can create one now.
No Subject Icon Selected
More info about formatting

Profile

deniok: (Default)
deniok

February 2022

S M T W T F S
  12345
6789101112
13141516171819
20212223 242526
2728     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Nov. 13th, 2025 03:59 am
Powered by Dreamwidth Studios