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:  Where to report an unfriendly feature (if not a bug) in
      `stack ghci`? (Jeffrey Brown)
   2. Re:  Storing the time difference between two Monotonic time
      results (David McBride)
   3.  Haskell for Imperative Programmers (Olivier Revollat)


----------------------------------------------------------------------

Message: 1
Date: Mon, 9 Jul 2018 14:29:46 -0500
From: Jeffrey Brown <jeffbrown....@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Where to report an unfriendly feature
        (if not a bug) in `stack ghci`?
Message-ID:
        <caec4ma3eqyixnt9-rldzfu0tzxaf-rxi-_5wq6hudxrahua...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Strange -- that page indicates the suggestion was applied, but when I try
it, it doesn't work:

    Configuring GHCi with the following packages:
    GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
    Loaded GHCi configuration from /tmp/ghci10227/ghci-script
    Prelude> :set prompt "> "
    > :{
    Prelude| 3
    Prelude| :}
    3
    > :set prompt2 "> "
    Some flags have not been recognized: prompt2, >
    > :{
    Prelude| 3
    Prelude| :}
    3
    >


On Wed, Jul 4, 2018 at 7:31 AM Ut Primum <utpri...@gmail.com> wrote:

> Hi,
> I think the same was reported here:
>
> https://ghc.haskell.org/trac/ghc/ticket/7509#no1
>
> Ut
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>


-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>   |   Facebook
<https://www.facebook.com/mejeff.younotjeff>   |   LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here)   |   Github <https://github.com/jeffreybenjaminbrown>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20180709/3d256fab/attachment-0001.html>

------------------------------

Message: 2
Date: Mon, 9 Jul 2018 15:52:00 -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] Storing the time difference between
        two Monotonic time results
Message-ID:
        <CAN+Tr43Dt1Bi+Ds=tpydfgj-6hun5+k8pyg6raw3mabx+4d...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

toList :: String -> [Integer]
toList input = read ("[" ++ input ++ "]")

That was creative, but a more idiomatic way to write that would be to use
the split package

stack ghci --package split

import Data.Split

toList :: String -> [Integer]
toList = fmap read . splitOn ","

As for how to aggregate times, start thinking about the types before you
start.  Each iteration you should take a List and return a TimeSpec.

testcase :: [Integer] -> IO TimeSpec
testcase l = do
  start <- getTime Monotonic
  evaluate (mergesort l)
  end <- getTime Monotonic
  return $ diffTimeSpec start end

Now, we need to run it 100 times and collect the times.  Sounds like a job
for map, but since testcase is monadic, use mapM instead (or traverse).

main = do
  unsortedList <- undefined
  times <- mapM (\c -> testcase unsortedList) [1..100]
  print times

On Mon, Jul 9, 2018 at 9:40 AM, Awsaf Rahman <awsafrahman1...@gmail.com>
wrote:

> Okay, here is what I am trying to do. I am trying to time this mergesort
> program. I want to run this program 100, 1000, etc times and store the
> timing results in a list if possible. Can't seem to figure out how to do
> it! The following program prints the timings to the shell and I need to
> figure out a way to store the timings in a list.
>
>
> {-# LANGUAGE OverloadedStrings #-}
> {-# LANGUAGE BangPatterns #-}
> import Control.Exception
> import Formatting
> import Formatting.Clock
> import System.Clock
> import Control.DeepSeq
>
> mergesort [] = []
> mergesort [x] = [x]
> mergesort xs = let (lhalf, rhalf) = splitAt (length xs `div` 2) xs
>                in merge' (mergesort lhalf) (mergesort rhalf)
>
> merge' lhalf rhalf = merge lhalf rhalf []
>
> merge [] [] acc = reverse acc
> merge [] y acc = reverse acc ++ y
> merge x [] acc = reverse acc ++ x
>
> merge (l:ls) (r:rs) acc
>         | l < r = merge ls (r:rs) (l:acc)
>         | otherwise = merge rs (l:ls) (r:acc)
>
> toList :: String -> [Integer]
> toList input = read ("[" ++ input ++ "]")
>
> repeater unsortedlist 0 result = return (result)
>
> repeater unsortedlist counter result = do
>                             start <- getTime Monotonic
>                             evaluate(mergesort unsortedlist)
>                             end <- getTime Monotonic
>                             fprint (timeSpecs % "\n") start end
>                             repeater unsortedlist (counter-1) result
>
> main = do
>     file <- getLine
>     contents <- readFile file
>     let !unsortedlist = (toList contents)
>     repeater unsortedlist 100 []
>
>
> On Mon, Jul 9, 2018 at 3:21 PM, David McBride <toa...@gmail.com> wrote:
>
>> I guess whatever version you are using did not export that function.  In
>> any case the definition for that function is incredibly simple, so you
>> could just write your own for now.
>>
>> diffTimeSpec :: TimeSpec -> TimeSpec -> TimeSpecdiffTimeSpec ts1 ts2 = abs 
>> (ts1 - ts2)
>>
>>
>>
>> On Mon, Jul 9, 2018 at 9:08 AM, Awsaf Rahman <awsafrahman1...@gmail.com>
>> wrote:
>>
>>> I imported the System.Clock module and tried to use the diffTimeSpec
>>> function but it keeps saying "out of scope".
>>>
>>> On Mon, Jul 9, 2018 at 2:45 PM, David McBride <toa...@gmail.com> wrote:
>>>
>>>> There is a diffTimeSpec function in that module that seems like it
>>>> would work.
>>>>
>>>> On Mon, Jul 9, 2018 at 8:30 AM, Awsaf Rahman <awsafrahman1...@gmail.com
>>>> > wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I am trying to time a function I have written in haskell using the
>>>>> clock package in the following way:
>>>>>
>>>>> *start <- getTime Monotonic*
>>>>> *evaluate(something)*
>>>>> *end <- getTime Monotonic*
>>>>> *fprint (timeSpecs % "\n") start end*
>>>>>
>>>>>
>>>>> Now what I want is to store the time difference between *start* and *end.
>>>>> *Is there a way I can do that?
>>>>>
>>>>> Regards
>>>>> Awsaf
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>>
>>>
>>> _______________________________________________
>>> 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
>>
>>
>
> _______________________________________________
> 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/20180709/ece38705/attachment-0001.html>

------------------------------

Message: 3
Date: Tue, 10 Jul 2018 11:22:17 +0200
From: Olivier Revollat <revol...@gmail.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] Haskell for Imperative Programmers
Message-ID:
        <ca+nxgrwb0p7rjw0ggbfotql+_-ogpmxcr9cwfepebax9uei...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,
I've been using imperative languages for 20 years now :)

I'm a beginner in haskell and I love the paradigm shift you feel when you
come from imperative programming. I found interesting articles like :
https://wiki.haskell.org/Haskell_IO_for_Imperative_Programmers

Do you have any other ressources like that ?
I'm not looking for how to use haskell in imperative style (e.g. with "do"
notation, ...) no no ! I'm looking articles who explain how NOT TO USE
imperative style with haskell, and help thinking the paradigm shift ...

Thanks :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20180710/ed5a23b7/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 121, Issue 8
*****************************************

Reply via email to