<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Vo,<br><br>Pardon, I grabbed the wrong lines.<br><br>*Main> :t (->) 3 "abc"<br><br><interactive>:1:1: parse error on input `->'<br><br>Michael<br><br>--- On <b>Tue, 8/31/10, Vo Minh Thu <i><noteed@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Vo Minh Thu <noteed@gmail.com><br>Subject: Re: [Haskell-cafe] On to applicative<br>To: "michael rice" <nowgate@yahoo.com><br>Cc: "Ryan Ingram" <ryani.spam@gmail.com>, haskell-cafe@haskell.org<br>Date: Tuesday, August 31, 2010, 3:07 PM<br><br><div class="plainMail">2010/8/31 michael rice <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>><br>><br>> Hi, Ryan and all,<br>><br>> Bingo! I guess my question was all right after
all.<br>><br>> I tried creating an instance earlier but<br>><br>> *Main> :t (->) Int Char<br>><br>> <interactive>:1:1: parse error on input `->'<br><br> :t Int<br>does not make sense but<br> :t undefined :: Int<br>is ok, just like<br> :t undefined :: (->) Int Int<br><br>> What got loaded with FmapFunc? I Hoogled it and got back nothing.<br>><br>> Michael<br>><br>> --- On Tue, 8/31/10, Ryan Ingram <<a ymailto="mailto:ryani.spam@gmail.com" href="/mc/compose?to=ryani.spam@gmail.com">ryani.spam@gmail.com</a>> wrote:<br>><br>> From: Ryan Ingram <<a ymailto="mailto:ryani.spam@gmail.com" href="/mc/compose?to=ryani.spam@gmail.com">ryani.spam@gmail.com</a>><br>> Subject: Re: [Haskell-cafe] On to applicative<br>> To: "michael rice" <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>><br>> Cc: "Vo Minh
Thu" <<a ymailto="mailto:noteed@gmail.com" href="/mc/compose?to=noteed@gmail.com">noteed@gmail.com</a>>, <a ymailto="mailto:haskell-cafe@haskell.org" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>> Date: Tuesday, August 31, 2010, 2:36 PM<br>><br>> Prelude FmapFunc> let s = show :: ((->) Int) String<br>> Prelude FmapFunc> :t s<br>> s :: Int -> String<br>> Prelude FmapFunc> let v = fmap ("hello " ++) s<br>> Prelude FmapFunc> :t v<br>> v :: Int -> String<br>> Prelude FmapFunc> v 1<br>> "hello 1"<br>><br>> -- ryan<br>><br>> On Tue, Aug 31, 2010 at 11:28 AM, michael rice <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>> wrote:<br>><br>> I'm not sure if my terminology is correct or even if my question makes sense, but I can create "instances" of Maybe, List, IO, and
Either.<br>><br>> Prelude Data.Either> let m = Just 7<br>> Prelude Data.Either> :t m<br>> m :: Maybe Integer<br>><br>> Prelude Data.Either> let l = 2:[]<br>> Prelude Data.Either> :t l<br>> l :: [Integer]<br>><br>> Prelude Data.Either> let g = getLine<br>> Prelude Data.Either> :t g<br>> g :: IO String<br>><br>> Prelude Data.Either> let e = Right "abc"<br>> Prelude Data.Either> :t e<br>> e :: Either a [Char]<br>><br>> All these instances are functors, each with its own version of fmap that can be applied to it.<br>><br>> How can I similarly create an instance of (->) so I can apply (->)'s version of fmap<br>><br>> instance Functor ((->) r) where<br>> fmap f g = (\x -> f (g x))<br>><br>> to it?<br>><br>> Michael<br>><br>> --- On Tue, 8/31/10, Vo Minh Thu <<a ymailto="mailto:noteed@gmail.com"
href="/mc/compose?to=noteed@gmail.com">noteed@gmail.com</a>> wrote:<br>><br>> From: Vo Minh Thu <<a ymailto="mailto:noteed@gmail.com" href="/mc/compose?to=noteed@gmail.com">noteed@gmail.com</a>><br>> Subject: Re: [Haskell-cafe] On to applicative<br>> To: "michael rice" <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>><br>> Cc: <a ymailto="mailto:haskell-cafe@haskell.org" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>> Date: Tuesday, August 31, 2010, 1:50 PM<br>><br>> 2010/8/31 michael rice <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>><br>> ><br>> > So it's a type constructor, not a type? Could you please provide a simple example of its usage?<br>><br>> Sure, although I'm sure you've come by some already.<br>><br>> -- the identity function<br>>
id :: a -> a<br>> -- often, we write it like this:<br>> -- id x = x<br>> -- but here we see the relationship between the ananymous function<br>> syntax and the function type:<br>> id = \x -> x<br>><br>> In fact, if you write in prefix form, it is quite familiar:<br>> f :: (->) Int Bool<br>> e = Either String Float<br>><br>> Cheers,<br>> Thu<br>><br>> > Michael<br>> ><br>> > --- On Tue, 8/31/10, Vo Minh Thu <<a ymailto="mailto:noteed@gmail.com" href="/mc/compose?to=noteed@gmail.com">noteed@gmail.com</a>> wrote:<br>> ><br>> > From: Vo Minh Thu <<a ymailto="mailto:noteed@gmail.com" href="/mc/compose?to=noteed@gmail.com">noteed@gmail.com</a>><br>> > Subject: Re: [Haskell-cafe] On to applicative<br>> > To: "michael rice" <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>><br>> > Cc: <a
ymailto="mailto:haskell-cafe@haskell.org" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>> > Date: Tuesday, August 31, 2010, 1:17 PM<br>> ><br>> > 2010/8/31 michael rice <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>><br>> > ><br>> > > "Learn You a Haskell ..." says that (->) is a type just like Either. Where can I find its type definition?<br>> ><br>> > You can't define it *in* Haskell as user code. It is a built-in infix<br>> > type constructor (Either or Maybe are type constructors too, not just<br>> > types). In fact, if you want to implement a simple, typed functional<br>> > language, you'll find it is the only built-in type constructor you<br>> > have to implement (as the implementor of the language).<br>> ><br>> > Also,<br>> > Show a => a<br>>
> is a type too, but you won't find a definition for 'a' or for '=>'.<br>> > All those things are defined by the language.<br>> ><br>> > Cheers,<br>> > Thu<br>> ><br>><br>><br>> _______________________________________________<br>> Haskell-Cafe mailing list<br>> <a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>><br>><br>><br></div></blockquote></td></tr></table><br>