Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  running shelly script from root's crontab (Miguel Negr?o)
   2. Re:  running shelly script from root's crontab (Emanuel Koczwara)
   3. Re:  running shelly script from root's crontab (Peter Jones)
   4. Re:  running shelly script from root's crontab (Miguel Negr?o)
   5.  coding style: instead of let, return? (Obscaenvs)
   6.  Example using gmapQ (Adrian May)
   7.  cps in yaht (Deng Wu)


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

Message: 1
Date: Fri, 12 Jul 2013 14:39:34 +0100
From: Miguel Negr?o <[email protected]>
Subject: [Haskell-beginners] running shelly script from root's crontab
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi

I have a shelly script that runs fine from my user account which I would 
to run every night. It needs to sudo to call some other processes so I 
need to add it to the root's crontab (sudo crontab -e). Unfortunately 
the script will fail to run because it can't find several modules, since 
it's running from the root account. Is there a way to make this work 
without having to install the packages globally (sudo cabal install 
--globally) ? I just tried that and manage to completely ruin my haskell 
installation, so I had to revert to previous backup.

thanks,
-- 
Miguel Negr?o
http://www.friendlyvirus.org/miguelnegrao



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

Message: 2
Date: Fri, 12 Jul 2013 15:59:16 +0200
From: Emanuel Koczwara <[email protected]>
Subject: Re: [Haskell-beginners] running shelly script from root's
        crontab
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID: <1373637556.15175.40.camel@emanuel-laptop>
Content-Type: text/plain; charset="utf-8"

Hi,

Dnia 2013-07-12, pi? o godzinie 14:39 +0100, Miguel Negr?o pisze: 
> Hi
> 
> I have a shelly script that runs fine from my user account which I would 
> to run every night. It needs to sudo to call some other processes so I 
> need to add it to the root's crontab (sudo crontab -e). Unfortunately 
> the script will fail to run because it can't find several modules, since 
> it's running from the root account. Is there a way to make this work 
> without having to install the packages globally (sudo cabal install 
> --globally) ? I just tried that and manage to completely ruin my haskell 
> installation, so I had to revert to previous backup.

  Try: 'su - user_name'

Best regards,
Emanuel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5185 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130712/547d213a/attachment-0001.bin>

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

Message: 3
Date: Fri, 12 Jul 2013 08:02:05 -0600
From: Peter Jones <[email protected]>
Subject: Re: [Haskell-beginners] running shelly script from root's
        crontab
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

Miguel Negr?o <[email protected]> writes:
> I have a shelly script that runs fine from my user account which I
> would to run every night. It needs to sudo to call some other
> processes so I need to add it to the root's crontab (sudo crontab
> -e). Unfortunately the script will fail to run because it can't find
> several modules, since it's running from the root account. Is there a
> way to make this work without having to install the packages globally
> (sudo cabal install --globally) ? I just tried that and manage to
> completely ruin my haskell installation, so I had to revert to
> previous backup.

Miguel, it sounds like you're using `runhaskell' to execute your code.
Is there any reason you can't compile the code using GHC?  With an
executable binary you wouldn't need anything from Haskell available to
the root user.

-- 
Peter Jones, Founder, Devalot.com
Defending the honor of good code




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

Message: 4
Date: Fri, 12 Jul 2013 15:34:37 +0100
From: Miguel Negr?o <[email protected]>
Subject: Re: [Haskell-beginners] running shelly script from root's
        crontab
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi Peter,

Em 12-07-2013 15:02, Peter Jones escreveu:
> Miguel Negr?o <[email protected]> writes:
>> I have a shelly script that runs fine from my user account which I
>> would to run every night. It needs to sudo to call some other
>> processes so I need to add it to the root's crontab (sudo crontab
>> -e). Unfortunately the script will fail to run because it can't find
>> several modules, since it's running from the root account. Is there a
>> way to make this work without having to install the packages globally
>> (sudo cabal install --globally) ? I just tried that and manage to
>> completely ruin my haskell installation, so I had to revert to
>> previous backup.
>
> Miguel, it sounds like you're using `runhaskell' to execute your code.
> Is there any reason you can't compile the code using GHC?  With an
> executable binary you wouldn't need anything from Haskell available to
> the root user.

Indeed, I was using runhaskell to avoid the compile step, but off 
course, the obvious solution is to compile to a binary, that works 
perfectly !

thanks,
-- 
Miguel Negr?o
http://www.friendlyvirus.org/miguelnegrao



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

Message: 5
Date: Sat, 13 Jul 2013 08:56:31 +0200
From: Obscaenvs <[email protected]>
Subject: [Haskell-beginners] coding style: instead of let, return?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Just a style question:

What's the community's verdict when it comes to using `return` to bind
names instead of `let`? E.g. if instead of
`
  let p1 <- mkName "p1"
  a <- newName "a"
`
, we use
`
  p1 <- return $ mkName "p1"
  a <- newName "a"
`.

I have seen this a couple of times in other people's code now, and I am
ambivalent about it: `let` states intention better, and refrains from
redundancy, but when you know why the writer behind the code is using
the `return`-variant, it's somewhat easier on the eyes (at least when
some actions in do-notation follow).

In my opinion, `let` *is* the better alternative, but there is code in
the wild[1] that uses the `return`-variant, so I wanted to gauge the
community's opinion on the matter.

[1] http://monads.haskell.cz/html/statemonad.html

--
fredrik






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

Message: 6
Date: Sat, 13 Jul 2013 16:48:49 +0800
From: Adrian May <[email protected]>
Subject: [Haskell-beginners] Example using gmapQ
To: "[email protected]" <[email protected]>
Message-ID:
        <cad-ubzg2c+1ypxsghjhum0c7pu18zc0brkm6nvmsatpraua...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi All,

I got this far:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveDataTypeable #-}
import Data.Text
import Data.Typeable
import Data.Data

data Thing = Thing { foo :: Int, bar :: String}
   deriving (Read, Show, Typeable, Data)
thing :: Thing
thing = Thing 1 "wop"
con = toConstr thing
fields = constrFields con
main = putStrLn $ show con ++ show fields ++ ( Prelude.concat $ gmapQ show
thing )

But it's barfing like this:

    Could not deduce (Show d) arising from a use of `show'
    from the context (Data d)
      bound by a type expected by the context: Data d => d -> [Char]
      at w.hs:76:65-80

I can see why, but not how to fix it.

Any help much appreciated,
Adrian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130713/74318a12/attachment-0001.htm>

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

Message: 7
Date: Sat, 13 Jul 2013 17:47:45 +0800
From: Deng Wu <[email protected]>
Subject: [Haskell-beginners] cps in yaht
To: [email protected]
Message-ID:
        <CALeUGJynruVSsPMucpbKUm=a15bnp7npcn9byhedzn7zwhi...@mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

hi, everyone,

I'm learning haskell by reading the book <<Yet Another Haskell Tutorial>>,
and I encounter a problem when comes to the contiuation passing style. The
book gives a  cps fold like:

cfold? f z [] = z
cfold? f z (x:xs) = f x z (\y -> cfold? f y xs)

and gives the test result:

CPS> cfold (+) 0 [1,2,3,4]
10
CPS> cfold (:) [] [1,2,3]
[1,2,3]

but, when I try to test this, I find there is a problem, the ghci gives:

-----------------------------------------------------------------------
*Main> cfold (+) 0 []

<interactive>:8:7:
    Occurs check: cannot construct the infinite type:
      t10 = (t10 -> t10) -> t10
    Expected type: t10 -> t10 -> (t10 -> t10) -> t10
      Actual type: t10 -> t10 -> t10
    In the first argument of `cfold', namely `(+)'
    In the expression: cfold (+) 0 []
    In an equation for `it': it = cfold (+) 0 []
------------------------------------------------------------------------

It makes sense to me, so I change the definition of cps to something like
this:

cfold f z [] = z
cfold f z (x:xs) = (\y -> cfold f y xs) (f x z)

And it works fine:

*Main> cfold (+) 0 [1,2,3]
6

So my question comes, is it a bug in the book or something I miss here?



Regards!
-
wudeng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130713/e033fbdd/attachment.htm>

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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 61, Issue 15
*****************************************

Reply via email to