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.  Re: Addable function combinators (edgar klerks)
   2.  Re: [OT] To the Google Group 'fa.haskell' admin.
      (Benjamin L. Russell)
   3. Re:  Re: overflow safe Word types (Ashish Agarwal)
   4.  hiding documentation for non-exposed modules (Ashish Agarwal)
   5.  Re: hiding documentation for non-exposed modules (Ashish Agarwal)
   6. Re:  What should I use (the equivalent of Windows schtasks)
      to schedule a task to run? (Brent Yorgey)
   7. Re:  Rewriting traversal over trees (Brent Yorgey)


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

Message: 1
Date: Mon, 29 Mar 2010 09:29:16 +0200
From: edgar klerks <[email protected]>
Subject: [Haskell-beginners] Re: Addable function combinators
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

A small erratum <*|||> has type (b -> c) (a -> a1 -> a2 -> b) a a1 a3 and it
is nicer to add more * by defining these functions:
con = (flip.) .(.)

(<**>) = flip
(<***>) = con (<**>)
(<****>) = con (<***>)
(<*****>) = con (<****>)


Then the serie of <**|> gets:

(<*****|>) = (<*|>).(<*****>)
(<****|>) = (<*|>).(<****>)
(<***|>) = (<*|>).(<***>)
(<**|>) = (<*|>).(<**>)
(<*|>) = (.)

Now they behave more like (.), Eg: <**|> :: (a -> b -> c) (a1 -> b) -> a1 ->
a -> c

And the rest becomes:

(<**||>) = (<*||>).(<**>)
(<**|||>) = (<*|>).(<**||>)
(<**||||>) = (<*|>).(<**|||>)
(<***||>) =  (<*||>).(<***>)
(<***|||>) = (<*|>).(<***||>)





On Mon, Mar 29, 2010 at 2:04 AM, edgar klerks <[email protected]>wrote:

> He All,
>
> I was toying a bit around and found a function, which combines an function
> of arity 1 with 2.
> Then I produced a whole sequence of these function, the number of * stands
> for the arity of the left function and the number of | stands for arity the
> right function. so <*|||> :: (b -> c -> d) -> (a -> c) -> a -> b -> d:
>
> (<*****|>) = flip (<*|||||>)
> (<****|>) = flip (<*||||>)
> (<***|>) = flip (<*|||>)
> (<**|>) = flip (<*||>)
> (<*|>) = (.)
> (<*||>) = (<*|>).(<*|>)
> (<*|||>) =(<*||>).(<*|>)
> (<*||||>) = (<*||>).(<*||>)
> (<*|||||>) = (<*||||>).(<*|>)
>
> con = (flip.) .(.)
> (<**||>) = (<*||>).flip
> (<**|||>) = (<*|>).(<**||>)
> (<**||||>) = (<*|>).(<**|||>)
> (<***||>) =  (<*||>).(con flip)
> (<***|||>) = (<*|>).(<***||>)
> (<****||>) = (<*||>).(con.con $ flip)
>
> I found it interesting, but now I am stuck. is it possible to make the
> stars addable instead of the | or both?
>
> Greets,
>
> Edgar
> Edgar
>
>
>



-- 
Flatliner ICT Service,
Email: [email protected],
Tel: +31727851429
Fax: +31848363080
Skype: edgar.klerks
Website: flatlinerict.nl
Adres: Koelmalaan 258,
1813JD, Alkmaar
Nederland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100329/b6a71236/attachment-0001.html

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

Message: 2
Date: Tue, 30 Mar 2010 03:04:37 +0900
From: [email protected] (Benjamin L. Russell)
Subject: [Haskell-beginners] Re: [OT] To the Google Group 'fa.haskell'
        admin.
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

aditya siram <[email protected]> writes:

> I noticed that my posts to the 'fa.haskell' Google group don't make it
> to the Haskell-Cafe archives and I suspect they are invisible to the
> Haskell-Cafe readers. They seem to be visible to only those who are
> subscribe to the Google Group.
>
> Conversely some of the other people's posts to Haskell-Cafe don't
> appear in the Google group.
>
> For instance I posted to this thread:
> http://www.haskell.org/pipermail/haskell-cafe/2010-March/075250.html
> and it is not in the Haskell-Cafe archives.
>
> And this response by Jeff Wheeler:
> http://www.haskell.org/pipermail/haskell-cafe/2010-March/075251.html
> is not visible in the Google Group.
>
> As of now I'll stop using the Google group, but I wanted to let someone know.
>
> Thanks ...

The fa.haskell newsgroup is a unidirectional Usenet gateway echoing the
Haskell, Haskell-Beginners, and Haskell-Cafe mailing lists; it was never
intended for direct posting.  For reference, please see the following
thread:

[Haskell] ANN: The Haskell-Beginners mailing list has now been added to the 
fa.haskell Usenet gateway.
http://www.mail-archive.com/[email protected]/msg21501.html

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
"Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ 



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

Message: 3
Date: Tue, 30 Mar 2010 14:44:22 -0400
From: Ashish Agarwal <[email protected]>
Subject: Re: [Haskell-beginners] Re: overflow safe Word types
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Thanks for the answers. These options should work. I don't actually need to
do arithmetic on these values, just construct values that are not
out-of-bounds. Thus efficiency is not a major concern.


On Sat, Mar 27, 2010 at 7:44 PM, Maciej Piechotka <[email protected]>wrote:

> On Fri, 2010-03-26 at 14:23 -0400, Ashish Agarwal wrote:
> > Is there an alternative implementation of the types Word8, Word16,
> > etc. that disallow overflow? For example, currently:
> >
> >
> > Prelude Word> (fromInteger 256) :: Word8
> > 0
> >
> >
> > I'd like a type whose constructors disallow this.
> >
> >
>
> safeConvert :: (Integral a, Integral b) :: a -> Maybe b
> safeConvert x | fromIntegral y == x = Just $! y
>              | otherwise           = Nothing
>              where y = fromIntegral x
>
> You can write:
>
> newtype Safe a = Safe a deriving Eq
>
> instance Show a => Show (Safe a) where
>        show (Safe x) = show x
>
> instance Integral a => Num (Safe a) where
>        (Safe x) + (Safe y) = Safe $! x + y
>        (Safe x) * (Safe y) = Safe $! x * y
>        (Safe x) - (Safe y) = Safe $! x - y
>        negate     (Safe y) = Safe $! negate y
>        abs        (Safe y) = Safe $! abs y
>        signum     (Safe y) = Safe $! signum y
>        fromInteger x       =
>          Safe $! fromMaybe (error "overflow") (safeConvert x)
>
> ...
>
> if you want
>
> Regards
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100330/cfd8afe4/attachment-0001.html

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

Message: 4
Date: Tue, 30 Mar 2010 14:55:16 -0400
From: Ashish Agarwal <[email protected]>
Subject: [Haskell-beginners] hiding documentation for non-exposed
        modules
To: Haskell-beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I'm using cabal to build and install a new library I'm writing. In the
.cabal file I've exposed only a single module. However, the haddock
generated documentation includes even the non-exposed modules, which is not
what I want since end-users should not see these. Is there a way to tell
cabal to build documentation only for exposed modules?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100330/6a23095c/attachment-0001.html

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

Message: 5
Date: Tue, 30 Mar 2010 15:47:26 -0400
From: Ashish Agarwal <[email protected]>
Subject: [Haskell-beginners] Re: hiding documentation for non-exposed
        modules
To: Haskell-beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

The pragma

{-# OPTIONS_HADDOCK hide #-}

does what I want, but it seems to me that cabal should be handling this.

On Tue, Mar 30, 2010 at 2:55 PM, Ashish Agarwal <[email protected]>wrote:

> I'm using cabal to build and install a new library I'm writing. In the
> .cabal file I've exposed only a single module. However, the haddock
> generated documentation includes even the non-exposed modules, which is not
> what I want since end-users should not see these. Is there a way to tell
> cabal to build documentation only for exposed modules?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100330/4202bf4d/attachment-0001.html

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

Message: 6
Date: Tue, 30 Mar 2010 18:38:22 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] What should I use (the equivalent of
        Windows schtasks) to schedule a task to run?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Fri, Mar 26, 2010 at 11:29:42PM -0500, Hong Yang wrote:
> I searched "schedul" on hayoo!, but had no clue. It seems that I can use
> scheduleEventAt from Control.Monad.Event.Classes. But what is type "e"? It
> seems like an event. How do I define an event?

I don't think that's what you want; Control.Monad.Event appears to be
for doing event-driven simulations, not for scheduling actual tasks on
your OS.  I am not sure how to do this but presumably there would have
to be a library with bindings to the OS's underlying calls.

> I have not learned Monad yet. Can some one give me a simple example? Suppose
> I want to run an external program "pg" which in Haskell's language has the
> type of String -> IO ().

Can you be more specific?  A "simple example of monads" is rather
vague; monads are used for quite a lot of things.  Have you read any
particular books or tutorials?

-Brent


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

Message: 7
Date: Tue, 30 Mar 2010 18:43:45 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Rewriting traversal over trees
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi Darryn,

This code looks very nice to me.  There probably are different ways to
do it, existing things it is related to, and so on, but if you want
that sort of commentary you will probably get a better response on the
[email protected] mailing list (where such a message would be
quite welcome).

-Brent

On Fri, Mar 26, 2010 at 04:53:27PM +1030, Darryn Reid wrote:
> 
> Hi, I hope that this is an appropriate place to post this question; I'm
> an experienced computer scientist and mathematician but am new to
> Haskell (I love it, I might add, but have much to learn).
> 
> I've coded a (fairly) general rewriting traversal - I suspect the
> approach might be generalisable to all tree-like types, but this doesn't
> concern me much right now. My purpose is for building theorem provers
> for a number of logics, separating the overall control mechanism from
> the specific rules for each logic.
> 
> The beauty of Haskell here is in being able to abstract the traversal
> away from the specific reduction rules and languages of the different
> logics. I have paired down the code here to numbers rather than modal
> formulas for the sake of clarity and simplicity. My question is
> two-fold:
> 1. Does my representation of the traversal seem good or would it be
> better expressed differently? If so, I'd appreciate the thoughts of more
> experienced Haskell users.
> 2. I cannot really see how to easily extend this to a queue-based
> breadth-first traversal. I'm sure others must have a good idea of how to
> do what I'm doing here except in breadth-first order; I'd appreciate it
> very much if someone could show me how to make a second breadth-first
> version.
> 
> Thanks in advance for any help!
> 
> Darryn.
> 
> start of code.
> -------------------------------------------------------------------------
> import Control.Monad
> import Control.Monad.Identity
> 
> -- Tableau is a tree containing formulas of type a, in 
> -- Fork (disjunctive) nodes and Single (conjunctive) nodes.
> -- Paths from root to Nil each represent an interpretation.
> data Tableau a =   Nil                           -- End of a path
>                  | Single a (Tableau a)          -- Conjunction
>                  | Fork (Tableau a) (Tableau a)  -- Disjunction
>                  deriving (Eq, Show)
> 
> -- 'Cut' directs the traversal to move back up the tree rather than into
> -- the current subtree, while 'Next' directs the traversal to proceed
> -- into the subtree.
> data Action = Cut | Next 
>               deriving (Eq, Show)
> 
> -- The type of the rewrite function to perform at each node in
> -- the traversal of the tree. The Rewriter returns the new
> -- subtree to replace the existing subtree rooted at the
> -- traversal node, and a direction controlling the traversal
> -- to the next node.
> type Rewriter m a = Tableau a -> m (Tableau a, Action)
> 
> -- The traversal function, depth-first order.
> rewrite :: (Monad m) => Rewriter m a -> Tableau a -> m (Tableau a)
> rewrite rf t = do (t', d) <- rf t
>                   rewrite' rf d t'
> 
> -- Worker function for traversal, really its main body.
> rewrite' :: (Monad m) => Rewriter m a -> Action -> Tableau a -> m
> (Tableau a)
> rewrite' rf Cut  t             = return t
> rewrite' rf Next Nil           = return Nil
> rewrite' rf Next (Single x t1) = do t1' <- rewrite rf t1
>                                     return (Single x t1')
> rewrite' rf Next (Fork t1 t2)  = do t1' <- rewrite rf t1
>                                     t2' <- rewrite rf t2
>                                     return (Fork t1' t2')
> 
> -- Some examples to test the code with:
> -- ghci> let t0 = (Single 2 (Single 3 Nil))
> -- ghci> let t1 = (Single 1 (Fork t0 (Fork (Single 4 Nil) (Single 5
> Nil))))
> -- ghci> let t2 = (Fork (Single 10 Nil) (Single 11 Nil))
> -- ghci> let t3 = (Fork (Single 3 Nil) (Single 3 Nil))
> 
> -- Running "test4 t1 t2" produces the expected result; running 
> -- "test4 t1 t3" does not terminate, because this endlessly 
> -- generates new patterns that match the substitution condition:
> test4 :: (Num t) => Tableau t -> Tableau t -> Tableau t
> test4 tab tab' = runIdentity (rewrite rf tab)
>             where rf (Single 3 Nil) = return (tab', Next)
>                   rf t              = return (t, Next)
> 
> -- Running "test5 t1 t3", however, does terminate because the "Cut"
> -- prevents the traversal from entering the newly spliced subtrees
> -- that match the pattern.
> test5 :: (Num t) => Tableau t -> Tableau t -> Tableau t
> test5 tab tab' = runIdentity (rewrite rf tab)
>             where rf (Single 3 Nil) = return (tab', Cut)
>                   rf t              = return (t, Next)
> -------------------------------------------------------------------------
> end of code.
> 
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners


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

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


End of Beginners Digest, Vol 21, Issue 30
*****************************************

Reply via email to