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. applicative default structure (Ovidiu Deac) 2. Re: applicative default structure (Imants Cekusins) 3. Re: applicative default structure (Ovidiu Deac) 4. Re: applicative default structure (David McBride) 5. Re: applicative default structure (Imants Cekusins) 6. Re: applicative default structure (Imants Cekusins) ---------------------------------------------------------------------- Message: 1 Date: Thu, 22 Dec 2016 17:06:48 +0200 From: Ovidiu Deac <ovidiud...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] applicative default structure Message-ID: <cakvse7umcsj8f0d+o7pye5jbc_chp9bapetqrotnyuvgcbh...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" This code is using Applicative Maybe. The structure is provided by Maybe and the value 1 is wrapped in this structure. No surprises here. Prelude> pure 1 :: Maybe Int Just 1 Prelude> :t (pure 1 :: Maybe Int) (pure 1 :: Maybe Int) :: Maybe Int ...but can somebody explain the type of x below? Prelude> x = pure 1 Prelude> x 1 Prelude> :t x x :: (Applicative f, Num a) => f a What is f here? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161222/cff0b753/attachment-0001.html> ------------------------------ Message: 2 Date: Thu, 22 Dec 2016 16:13:37 +0100 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] applicative default structure Message-ID: <cap1qinac6tz7uvj2okrsxrotd1dmswnzfnoj4ynssw2n442...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" > What is f here? anything Applicative: Prelude> let a1 = pure 1 Prelude> let a2 = pure 1 Prelude> (a1::Maybe Int) == a2 True Prelude> (a1::Maybe Float) == a2 True Prelude> (a1::Either String Float) == a2 True -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161222/13b7cfe8/attachment-0001.html> ------------------------------ Message: 3 Date: Thu, 22 Dec 2016 17:18:16 +0200 From: Ovidiu Deac <ovidiud...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] applicative default structure Message-ID: <cakvse7s22p8dkfc9rgxezv4tj8hikbtbx54ckb5o7smbwpm...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" My understanding is that x can take any form required for type-inference. That's fine but what is the "default" structure if you don't specify any? On Thu, Dec 22, 2016 at 5:13 PM, Imants Cekusins <ima...@gmail.com> wrote: > > What is f here? > > anything Applicative: > > Prelude> let a1 = pure 1 > Prelude> let a2 = pure 1 > > Prelude> (a1::Maybe Int) == a2 > True > Prelude> (a1::Maybe Float) == a2 > True > Prelude> (a1::Either String Float) == a2 > True > > > > > _______________________________________________ > 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/20161222/afdc046d/attachment-0001.html> ------------------------------ Message: 4 Date: Thu, 22 Dec 2016 10:33:41 -0500 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] applicative default structure Message-ID: <CAN+Tr430TySk4wo+W87d=naxqkfkexrkvq+n8aj+ssmqhps...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Rather than bailing with an instance error for both Applicative and Num, which is the technically the right way, and the way that it used to be in the dark ages of ghci. Instead it chooses types which are probably what you wanted. In this case it defaults f to IO and a to Int, and then runs it. You can read more about type defaulting in ghci here: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html On Thu, Dec 22, 2016 at 10:18 AM, Ovidiu Deac <ovidiud...@gmail.com> wrote: > My understanding is that x can take any form required for type-inference. > That's fine but what is the "default" structure if you don't specify any? > > On Thu, Dec 22, 2016 at 5:13 PM, Imants Cekusins <ima...@gmail.com> wrote: > >> > What is f here? >> >> anything Applicative: >> >> Prelude> let a1 = pure 1 >> Prelude> let a2 = pure 1 >> >> Prelude> (a1::Maybe Int) == a2 >> True >> Prelude> (a1::Maybe Float) == a2 >> True >> Prelude> (a1::Either String Float) == a2 >> True >> >> >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > > _______________________________________________ > 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/20161222/a7a24a04/attachment-0001.html> ------------------------------ Message: 5 Date: Thu, 22 Dec 2016 16:38:09 +0100 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] applicative default structure Message-ID: <CAP1qinaTb35irbwGnpVP49qhoAPb7mFzoT4U-L=gnpta_bb...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" > what is the "default" structure if you don't specify any similar to: display::Show a => a -> String display = show fa::(Applicative f, Num a) => f a fa = pure 1 f and a are *bounded* by Applicative and Num, so to say. No default. Or, it is typed however type is a bit broader than * > In this case it defaults f to IO and a to Int, does it though? Prelude> let a1 = pure 1 Prelude> let a2 = pure 1 Prelude> a1 == a2 <interactive>:20:1: error: • Ambiguous type variable ‘a0’ arising from a use of ‘a1’ prevents the constraint ‘(Num a0)’ from being solved. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161222/52dc05c1/attachment-0001.html> ------------------------------ Message: 6 Date: Thu, 22 Dec 2016 16:45:58 +0100 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] applicative default structure Message-ID: <cap1qinyrs_pbxzqcuhqdizsjcvhe_-gb8aemiie5wznqxlv...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" > type is a bit broader than * ignore this phrase. it is incorrect. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161222/007eb1dd/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 102, Issue 12 ******************************************