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:  What does the "!n" mean? (yi lu)
   2.  rolling my own split (abraham polishchuk)
   3. Re:  rolling my own split (David McBride)
   4. Re:  Hello World (Henk-Jan van Tuyl)
   5.  Haskell Weekly News (harry)


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

Message: 1
Date: Thu, 27 Mar 2014 09:26:26 +0800
From: yi lu <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] What does the "!n" mean?
Message-ID:
        <CAKcmqqy01Ez-kzS=Hj69icXpH6K-r=fdbonhzn+wuaqfcnw...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/bang-patterns.html

Do you mean this?


On Thu, Mar 27, 2014 at 9:15 AM, John M. Dlugosz
<[email protected]>wrote:

> I'm reading http://www.haskell.org/haskellwiki/IO_inside#inlinePerformIOand 
> it shows a passage of code:
>
> write :: Int -> (Ptr Word8 -> IO ()) -> Put ()
> write !n body = Put $ \c buf@(Buffer fp o u l) ->
>   if n <= l
>     then write' c fp o u l
>     else write' (flushOld c n fp o u) (newBuffer c n) 0 0 0
>
>   where {-# NOINLINE write' #-}
>         write' c !fp !o !u !l =
>           -- warning: this is a tad hardcore
>           inlinePerformIO
>             (withForeignPtr fp
>               (\p -> body $! (p `plusPtr` (o+u))))
>           `seq` c () (Buffer fp o (u+n) (l-n))
>
> I got as far as the second line, looking things up in this index <
> http://hackage.haskell.org/package/base-4.6.0.1/docs/doc-index.html>
>
> But ?write !n body = ??
> I understand write is defined to be a function taking an Int and another
> function,
> but what does !n mean?  I went through the 2010 Report (BTW, the PDF is
> useless for searching for the ! character so I used the HTML version
> page-by-page) and found it used as a modifier for named record fields (it
> says "strict" but I think it's describing non-optional).
> Then I went through the GHC users guide for language extensions, and found
> a reference in ?7.2.1 without explanation but as an example where the
> difference between
>         f x = let (Foo a b, w) = ..rhs.. in ..body..
> and     f x = let !(Foo a b, w) = ..rhs.. in ..body..
> is "you must make any such pattern-match strict".
> Strict pattern matching is not mentioned elsewhere nor is it in the
> Haskell Report, so what am I missing?  I suspect that the usage I'm asking
> about is related.
>
> The GHC users guide also mentions it again in ?7.4.6 which I think is a
> reference to the same feature, ?You can use strictness annotations, in the
> obvious places in the constructor type? but that's for use with a
> completely different extension (GADT types)
>
> I also recognize the ?@? mark as naming the entire variable rather than
> just the parts of the pattern matched, but ?buf? is not actually used
> anywhere, so does it mean something different, or has other effects, or
> what?
>
> Thanks in advance,
> ?John
>
> _______________________________________________
> 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/20140327/726c267d/attachment-0001.html>

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

Message: 2
Date: Wed, 26 Mar 2014 21:41:03 -0700
From: abraham polishchuk <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] rolling my own split
Message-ID:
        <cak0fm_bxgucgu9g7rcokazbcbvjlgwtznpl+t2rtbhmoh2z...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I am relatively new to Haskell, having spent the last half a decade or so
developing in Ruby. I am attempting to (for the sake of exercise) implement
a split function from the ground up in Haskell, and for the life of me I
can not figure out why it doesn't work. Without further ado:


    module MyAwesomeModule where

    import qualified Data.Text as T

    outputSplit :: String -> [String] -> IO ()
    outputSplit s tokens = print $ splitRecursive tokens s

    splitRecursive :: [String] -> String -> [String]
    splitRecursive tokens s = splitOneOf tokens s

    splitOneOf :: [String] -> String -> [String]
    splitOneOf [] s = []
    splitOneOf (t:tokens) s =  map (splitOneOf tokens)(map (T.unpack)
(T.splitOn (T.pack t) (T.pack s))) ++ (splitOneOf tokens s)


which errors out with:
   Couldn't match type `[Char]' with `Char'
    Expected type: String -> String
      Actual type: String -> [String]
    In the return type of a call of `splitOneOf'
    In the first argument of `map', namely `(splitOneOf tokens)'
    In the first argument of `(++)', namely
      `map
         (splitOneOf tokens)
         (map (T.unpack) (T.splitOn (T.pack t) (T.pack s)))'
Failed, modules loaded: none.


If anyone has any ideas, that would be awesome! And yes, I'm aware of
Data.List.Split, like I said, trying to roll my own....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140326/c74712f1/attachment-0001.html>

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

Message: 3
Date: Thu, 27 Mar 2014 01:32:02 -0400
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] rolling my own split
Message-ID:
        <can+tr42veolv5dpujyfj1lvgyp-mxvobglyaw_pedyg5018...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

You map something that returns [String] over a [String] and you get back
[[String]], but your function returns [String].  Keep in mind that Strings
are Lists of Chars, so ghc is a little confused about what you intended.

>:t map (splitOneOf undefined)
map (splitOneOf undefined) :: [String] -> [[String]]


Just to make things easier, first thing I'd do is take the spliton stuff
and put it in its own function.  Since all it is is a T.splitOn but for
strings, we'll just do that:

sSplitOn :: String -> String -> [String]
sSplitOn t s = map (T.unpack) ((T.pack t) `T.splitOn` (T.pack s))

And then I guessed at what you wanted out of this function, that is to run
splitOn on each item?  It seems like you would have gotten it if this was
what you wanted, but it's all I could figure out.  I'm probably wrong, but
in case this is what you wanted here it is.

splitOneOf :: [String] -> String -> [String]
splitOneOf [] s = []
splitOneOf (t:tokens) s = (sSplitOn t s) ++ splitOneOf tokens s

If this wasn't what you were looking for, it would help to have some
examples of input and output.


On Thu, Mar 27, 2014 at 12:41 AM, abraham polishchuk <[email protected]>wrote:

> I am relatively new to Haskell, having spent the last half a decade or so
> developing in Ruby. I am attempting to (for the sake of exercise) implement
> a split function from the ground up in Haskell, and for the life of me I
> can not figure out why it doesn't work. Without further ado:
>
>
>     module MyAwesomeModule where
>
>     import qualified Data.Text as T
>
>     outputSplit :: String -> [String] -> IO ()
>     outputSplit s tokens = print $ splitRecursive tokens s
>
>     splitRecursive :: [String] -> String -> [String]
>     splitRecursive tokens s = splitOneOf tokens s
>
>     splitOneOf :: [String] -> String -> [String]
>     splitOneOf [] s = []
>     splitOneOf (t:tokens) s =  map (splitOneOf tokens)(map (T.unpack)
> (T.splitOn (T.pack t) (T.pack s))) ++ (splitOneOf tokens s)
>
>
> which errors out with:
>    Couldn't match type `[Char]' with `Char'
>     Expected type: String -> String
>       Actual type: String -> [String]
>     In the return type of a call of `splitOneOf'
>     In the first argument of `map', namely `(splitOneOf tokens)'
>     In the first argument of `(++)', namely
>       `map
>          (splitOneOf tokens)
>          (map (T.unpack) (T.splitOn (T.pack t) (T.pack s)))'
> Failed, modules loaded: none.
>
>
> If anyone has any ideas, that would be awesome! And yes, I'm aware of
> Data.List.Split, like I said, trying to roll my own....
>
> _______________________________________________
> 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/20140327/2bdc563a/attachment-0001.html>

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

Message: 4
Date: Thu, 27 Mar 2014 08:24:30 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
To: [email protected], "John M. Dlugosz"
        <[email protected]>
Subject: Re: [Haskell-beginners] Hello World
Message-ID: <op.xdddi4fwpz0j5l@zen5>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

On Wed, 26 Mar 2014 23:40:14 +0100, John M. Dlugosz  
<[email protected]> wrote:

> My primary machine runs Windows 7.  I have Haskell Platform working OK  
> including GCHi-Win, but could not get Lekseh to work.

You can download a binary from
   http://leksah.org/news.html#r01200

Regards,
Henk-Jan van Tuyl


-- 
Folding@home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--


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

Message: 5
Date: Thu, 27 Mar 2014 08:01:16 +0000 (UTC)
From: harry <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Haskell Weekly News
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

The last edition of HWN was in December. Is it defunct, or just hibernating?
(This probably belongs on haskell-cafe, but for some reason it's not
accepting my email.)



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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 69, Issue 38
*****************************************

Reply via email to