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. List of a Data Type (Thomas Jakway) 2. Re: List of a Data Type (Alex Hammel) 3. Re: List of a Data Type (Ozgur Akgun) 4. Re: List of a Data Type (Thomas Jakway) 5. Add parenthesis to Sin/Cos expressions (goforgit .) 6. Re: Add parenthesis to Sin/Cos expressions (Imants Cekusins) 7. Re: randmomR produces only even values (Dominic Steinitz) ---------------------------------------------------------------------- Message: 1 Date: Tue, 3 Nov 2015 17:24:05 -0500 From: Thomas Jakway <tjak...@nyu.edu> To: beginners@haskell.org Subject: [Haskell-beginners] List of a Data Type Message-ID: <56393405.5010...@nyu.edu> Content-Type: text/plain; charset=utf-8; format=flowed I've made a new datatype data Visibility a = Hidden a | Shown a I want to create a type that's a list of hidden and visible integers. So something like this: type possiblyVisibleInts = [Visibility Int] The idea is that some of the ints will be hidden and some will be shown. But it doesn't work. Why not? This seemed even odder to me after poking around in ghci: :t [Just 5, Nothing] gives [Just 5, Nothing] :: Num a => [Maybe a] So clearly it's possible to have a list of a type that has 2 constructors--you're not restricted to having a list that only contains Just, for example. ghci is also OK with e.g. :t [Hidden 5, Shown 6] [Hidden 5, Shown 6] :: Num a => [Visibility a] ------------------------------ Message: 2 Date: Tue, 03 Nov 2015 22:34:19 +0000 From: Alex Hammel <ahamme...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] List of a Data Type Message-ID: <ca+_xfep2mgwjerqvxcaxejwtmpd20fhfy_2zr59fowmrmze...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Works for me: Prelude> data Vis a = Hidden a | Shown a Prelude> :t [Hidden "foo", Shown "bar"] [Hidden "foo", Shown "bar"] :: [Vis [Char]] Prelude> type VisListInt = [Vis Int] Prelude> let foo = (id :: VisListInt -> VisListInt) Prelude> :t foo foo :: VisListInt -> VisListInt Prelude> :t foo [Hidden 2] foo [Hidden 2] :: VisListInt What error message are you seeing? Cheers, Alex On Tue, 3 Nov 2015 at 14:24 Thomas Jakway <tjak...@nyu.edu> wrote: > I've made a new datatype > > data Visibility a = Hidden a | Shown a > > I want to create a type that's a list of hidden and visible integers. > So something like this: > > type possiblyVisibleInts = [Visibility Int] > > The idea is that some of the ints will be hidden and some will be shown. > > But it doesn't work. Why not? > This seemed even odder to me after poking around in ghci: > > :t [Just 5, Nothing] > gives > [Just 5, Nothing] :: Num a => [Maybe a] > > So clearly it's possible to have a list of a type that has 2 > constructors--you're not restricted to having a list that only contains > Just, for example. > > ghci is also OK with e.g. > > :t [Hidden 5, Shown 6] > [Hidden 5, Shown 6] :: Num a => [Visibility a] > _______________________________________________ > 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/20151103/135b3c25/attachment-0001.html> ------------------------------ Message: 3 Date: Tue, 3 Nov 2015 22:45:18 +0000 From: Ozgur Akgun <ozgurak...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] List of a Data Type Message-ID: <CALzazPC81-8oRXhCNtqVHmL53Vh1z=6b1mpywhbydrp0h_2...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" On 3 November 2015 at 22:24, Thomas Jakway <tjak...@nyu.edu> wrote: > type possiblyVisibleInts = [Visibility Int] > The case of the first letter is important: for type names, the first letter has to be capital. Ozgur -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151103/ae9ee07d/attachment-0001.html> ------------------------------ Message: 4 Date: Tue, 3 Nov 2015 17:59:29 -0500 From: Thomas Jakway <tjak...@nyu.edu> To: beginners@haskell.org Subject: Re: [Haskell-beginners] List of a Data Type Message-ID: <56393c51.9040...@nyu.edu> Content-Type: text/plain; charset="windows-1252"; Format="flowed" Woops, thanks a ton! On 11/3/15 5:45 PM, Ozgur Akgun wrote: > > On 3 November 2015 at 22:24, Thomas Jakway <tjak...@nyu.edu > <mailto:tjak...@nyu.edu>> wrote: > > type possiblyVisibleInts = [Visibility Int] > > > The case of the first letter is important: for type names, the first > letter has to be capital. > > Ozgur > > > > _______________________________________________ > 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/20151103/57c0d0fc/attachment-0001.html> ------------------------------ Message: 5 Date: Wed, 4 Nov 2015 08:29:24 +0100 From: "goforgit ." <teztin...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Add parenthesis to Sin/Cos expressions Message-ID: <CAHzzbMAzWoAqPim1bbqCE87bpV+vfgUxX0_a=1qbndnjhwd...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hello! I've written a function that is supposed to add parenthesis to sin/cos expressions. For example - Sin5+3 -> Sin(5) + 3 - SinCos(5+3) -> Sin(Cos(5+3)) - SinCos5 * 3 -> Sin(Cos(5)) * 3 The problem is that it converts the following expression *SinSin(5+1+2)* into *Sin(Sin(5)+1+2)* Could someone point me to the direction of a solution to this? Thanks in advance! convert :: String -> String convert s = convert' s 0 convert' :: String -> Int -> String convert' [] n = replicate n ')' convert' (a:as) n | ((a == 'n' || a == 's') && ((take 1 as) /= "(")) = a : "(" ++ (convert' as (n+1)) | ((a == '+' || a == '*') && (n > 0)) = (replicate n ')') ++ [a] ++ (convert' as 0) | otherwise = a : (convert' as n) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151104/2babc678/attachment-0001.html> ------------------------------ Message: 6 Date: Wed, 4 Nov 2015 10:21:18 +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] Add parenthesis to Sin/Cos expressions Message-ID: <cap1qinyzbk6omziwuwy1ao+punq4qdogda79jwxz5jfipsp...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 > a function that is supposed to add parenthesis to sin/cos expressions. a) Sin 5 + 3 -> Sin(5) + 3 b) Sin Cos (5+3) -> Sin (Cos(5+3)) c) Sin Cos 5 * 3 -> Sin(Cos(5)) * 3 are you looking for textual representation or actual Haskell code which runs? if actual code, these examples may be re-written like this: a) sin 5 + 3 b) sin $ cos $ 5 + 3 c) sin (cos 5) * 3 ------------------------------ Message: 7 Date: Wed, 4 Nov 2015 09:58:15 +0000 (UTC) From: Dominic Steinitz <domi...@steinitz.org> To: beginners@haskell.org Subject: Re: [Haskell-beginners] randmomR produces only even values Message-ID: <loom.20151104t105510-...@post.gmane.org> Content-Type: text/plain; charset=us-ascii > http://article.gmane.org/gmane.comp.lang.haskell.beginners/15925 I do think this is a flaw and catches many people out despite apparently being well documented. And it's something one probably wants e.g. to run multiple Markov Chain Monte Carlo simulations in parallel. Some further information here: https://github.com/haskell/random/issues/30#issuecomment-153647055 Dominic ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 89, Issue 5 ****************************************