Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: type T' = T a b c (David McBride) 2. Re: type T' = T a b c (Imants Cekusins) 3. Re: type T' = T a b c (Theodore Lief Gannon) 4. Re: type T' = T a b c (Imants Cekusins) 5. Re: type T' = T a b c (Imants Cekusins) 6. Functions as Applicatives (Olumide) 7. Re: Functions as Applicatives (Imants Cekusins) ---------------------------------------------------------------------- Message: 1 Date: Mon, 22 Aug 2016 08:23:18 -0400 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] type T' = T a b c Message-ID: <CAN+Tr42k2ibvTtpvojJRgiC3eb=zkva2bwdg7xtcplbsn4s...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" If you want to have something that can ignore a variable, you can just fill it in with (). T Int Char () (), then have a function :: T a b () () -> IO (). You can clean it up a little by making type aliases. type T2 a b = T a b () (), type T3 a b c = T a b c (). On Mon, Aug 22, 2016 at 7:32 AM, Imants Cekusins <ima...@gmail.com> wrote: > T' and T a b seem to not mix well. > > T' can not be passed to a function expecting T a b and vice versa > > any suggestions? > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160822/539fa0c3/attachment-0001.html> ------------------------------ Message: 2 Date: Mon, 22 Aug 2016 14:40:52 +0200 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] type T' = T a b c Message-ID: <cap1qinbxptpuois4uafbr75r1sgwwlgs3uwcvnypym5+t_n...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" David, this seem to work similar to forall...: synonym is not compatible with T a b. you see, I hope to mix synonym with original T a b in a chain of fun calls. Some of the funs accept args like this: fun1::T a b -> a -> out1 .. and others - like this: fun2::T' -> out2 in both cases a and b are not set. However in fun1 I try to enforce type 'a' in the arg #2. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160822/f03f5280/attachment-0001.html> ------------------------------ Message: 3 Date: Mon, 22 Aug 2016 05:45:46 -0700 From: Theodore Lief Gannon <tan...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] type T' = T a b c Message-ID: <CAJoPsuD7K=k3z83ZLizcoG+pyZW56-zmMuEaNtLi=rgz3xt...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Go in the other direction? data T a b = T a b type T2 a b c = T a (b, c) type T3 a b c d = T a (b, c, d) On Aug 22, 2016 5:40 AM, "Imants Cekusins" <ima...@gmail.com> wrote: > David, this seem to work similar to forall...: > > synonym is not compatible with T a b. > > you see, I hope to mix synonym with original T a b in a chain of fun > calls. > > Some of the funs accept args like this: > fun1::T a b -> a -> out1 > > .. and others - like this: > fun2::T' -> out2 > > in both cases a and b are not set. However in fun1 I try to enforce type > 'a' in the arg #2. > > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160822/18a54b92/attachment-0001.html> ------------------------------ Message: 4 Date: Mon, 22 Aug 2016 14:51:13 +0200 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] type T' = T a b c Message-ID: <CAP1qinZJsQt=jKE+cyD0Mqfnmsyd558cjwZ=nyrr9nso4h5...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" > data T a b = T a b > type T2 a b c = T a (b, c) how would this work if T were a record? say: data T a b = T { a::a, b::b, agnostic::Int } could we make a T' (no param) out of it? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160822/ec906bc4/attachment-0001.html> ------------------------------ Message: 5 Date: Mon, 22 Aug 2016 14:56:39 +0200 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] type T' = T a b c Message-ID: <CAP1qinZK=GnsFPzSHerFKM51A6Vj2e1ynkcXhQ=in_wvu3a...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" ok this may be it: data T a = T { a::a, common::Int } type T' a b = T (a,b) # of record fields stays the same however we cram more data into the 'a' field. it surely works. Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160822/edd9ab99/attachment-0001.html> ------------------------------ Message: 6 Date: Mon, 22 Aug 2016 17:07:30 +0100 From: Olumide <50...@web.de> To: beginners@haskell.org Subject: [Haskell-beginners] Functions as Applicatives Message-ID: <cac2fab2-bcf0-750b-fa6d-cef1bd270...@web.de> Content-Type: text/plain; charset=utf-8; format=flowed Hi List, I'm struggling to relate the definition of a function as a function instance Applicative ((->) r) where pure x = (\_ -> x) f <*> g = \x -> f x (g x) with the following expression ghci> :t (+) <$> (+3) <*> (*100) (+) <$> (+3) <*> (*100) :: (Num a) => a -> a ghci> (+) <$> (+3) <*> (*100) $ 5 508 From chapter 11 of LYH http://goo.gl/7kl2TM . I understand the explanation in the book: "we're making a function that will use + on the results of (+3) and (*100) and return that. To demonstrate on a real example, when we did (+) <$> (+3) <*> (*100) $ 5, the 5 first got applied to (+3) and (*100), resulting in 8 and 500. Then, + gets called with 8 and 500, resulting in 508." The problem is that I can't relate that explanation with the definition of a function as an applicative; especially f <*> g = \x -> f x (g x) . Is (g x) the second argument to f? Regards, - Olumide ------------------------------ Message: 7 Date: Mon, 22 Aug 2016 19:34:11 +0200 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Functions as Applicatives Message-ID: <cap1qinbk18ejwe9hthrfecw0jnkf8rvy1loflh21kk3eu-e...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hello Ollumide, this may help: it builds and runs anyway. {- instance Applicative ((->) r) where pure x = (\_ -> x) f <*> g = \x -> f x (g x) with the following expression ghci> :t (+) <$> (+3) <*> (*100) (+) <$> (+3) <*> (*100) :: (Num a) => a -> a ghci> (+) <$> (+3) <*> (*100) $ 5 508 -} f::Num f => f -> f -> f f = (+) g::Num g => g -> g g = (+ 3) h::Num h => h -> h h = (* 100) fg::Num a => a -> a -> a fg = f <$> g {- fg a b = a + (b + 3) fg a = \b -> a + (b + 3) -} fgh::Num a => a -> a fgh = fg <*> h {- fgh b = fg (b * 100) fgh = \b -> fg (b * 100) -} -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160822/6ea7ca9b/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 98, Issue 14 *****************************************