Send Beginners mailing list submissions to
        [email protected]

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
        [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:  help with music application (Dennis Raddle)
   2. Re:  help with music application (Michael Martin)
   3. Re:  help with music application (Christopher Allen)
   4. Re:  help with music application (Dennis Raddle)
   5.  More type errors I'm having trouble with (Dan Stromberg)


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

Message: 1
Date: Tue, 1 Dec 2015 15:22:53 -0800
From: Dennis Raddle <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] help with music application
Message-ID:
        <CAKxLvoqz2t2Lxab5Eta=-gt8YspnjdA=onzy0zo7vrb-md3...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Tue, Dec 1, 2015 at 3:13 PM, Christopher Allen <[email protected]> wrote:

> Could you post the code to a public repository? Ideally with some example
> input and expected output if you're that far along.
>
>

It's running fine and mostly complete right now, so just as an aside this
is a rewrite project to make it cleaner and easily to modify in the future.
But about posting it, it's pretty enormous, many files grouped into about
eight modules. What do you recommend I do? Create a BitBucket repository?

D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151201/0ca7bf3f/attachment-0001.html>

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

Message: 2
Date: Tue, 1 Dec 2015 17:30:00 -0600
From: Michael Martin <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] help with music application
Message-ID:
        <CAB1-XS=-tjN+AOTdSKwu2SXM=-zrrutzwhc0+pdfswxkmfy...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Github
On Dec 1, 2015 5:23 PM, "Dennis Raddle" <[email protected]> wrote:

>
>
> On Tue, Dec 1, 2015 at 3:13 PM, Christopher Allen <[email protected]>
> wrote:
>
>> Could you post the code to a public repository? Ideally with some example
>> input and expected output if you're that far along.
>>
>>
>
> It's running fine and mostly complete right now, so just as an aside this
> is a rewrite project to make it cleaner and easily to modify in the future.
> But about posting it, it's pretty enormous, many files grouped into about
> eight modules. What do you recommend I do? Create a BitBucket repository?
>
> D
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151201/8891a2fd/attachment-0001.html>

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

Message: 3
Date: Tue, 1 Dec 2015 17:37:24 -0600
From: Christopher Allen <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] help with music application
Message-ID:
        <CADnndOotcB=uK+J7P5mNJ59gDUWhcqWoG_=8ox8pxagmngg...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Github or Bitbucket are fine, according to your preference. Some people
might complain if it's not Github since there's more people there. I
personally don't care.

On Tue, Dec 1, 2015 at 5:22 PM, Dennis Raddle <[email protected]>
wrote:

>
>
> On Tue, Dec 1, 2015 at 3:13 PM, Christopher Allen <[email protected]>
> wrote:
>
>> Could you post the code to a public repository? Ideally with some example
>> input and expected output if you're that far along.
>>
>>
>
> It's running fine and mostly complete right now, so just as an aside this
> is a rewrite project to make it cleaner and easily to modify in the future.
> But about posting it, it's pretty enormous, many files grouped into about
> eight modules. What do you recommend I do? Create a BitBucket repository?
>
> D
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Chris Allen
Currently working on http://haskellbook.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151201/c06ad2b7/attachment-0001.html>

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

Message: 4
Date: Tue, 1 Dec 2015 16:05:57 -0800
From: Dennis Raddle <[email protected]>
To: Andrew Bernard <[email protected]>, Haskell Beginners
        <[email protected]>
Subject: Re: [Haskell-beginners] help with music application
Message-ID:
        <cakxlvoqged337zge26soehax82hvwo4ysk4pjr+ctvf+e61...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Tue, Dec 1, 2015 at 3:24 PM, Andrew Bernard <[email protected]>
wrote:

> Hi Dennis,
>
> This is a massively difficult and long task, fun of musical complexity.
> Are you aware of lilypond, the open source engraving program? It can export
> to MIDI and has been developed for over twenty years by hundreds of people.
> It is not written in Haskell, but C++ and Scheme principally.
>
> Not meaning to disparage your work in any way, but it does seem you are
> reinventing the wheel, and a rather big and complicated wheel. I am sure it
> is an interesting exercise, and perhaps Sibelius does not play MIDI ? I use
> lilypond so I do not know.
>
> Help you don?t mind me letting you know.
>
>
Hi Andrew, I'm copying the list on this message because these are some
relevant questions to the task as a whole. I am aware of LilyPond, and I
also own two commercial programs, Finale and Sibelius. Here are the reasons
I am reinventing the wheel.

1. I want to experiment with algorithms that introduce "human expression"
into the playback. Finale, Sibelius, and Lilypond can export to MIDI, but
the results sound mechanical and lifeless -- to my picky ears, anyway.
(many composers don't mind). Actually, Sibelius claims to use "human
expression" but my point is that I want to experiment with my own
algorithms and I want to be able to get into the source code to implement
and modify things.

2. Trying to get the musical data into my program via exporting from
Sibelius or Finale to MIDI won't work. MIDI is poor way to express musical
structures, and cannot represent symbols and expressive marks in the score.

3. Here's one of the most significant factors. I didn't mention anything
yet about what happens to the MIDI after I produce it. What happens is that
I feed it to a "software synthesizer." This is a program that produces
sound, by simulating or playing little bits of prerecorded notes. Here's
what is a big deal -- there is hardly any standard for how software
synthesizers respond to MIDI, especially all the control events. And every
software synthesizer has custom capabilities. Finale and Sibelius claim to
be able to do special controlling of the most popular synthesizers, but
their capability is limited to one or two at most, and it actually hard to
control (and maybe even buggy). I own three very good synthesizers, and two
of them have controls that Sibelius and Finale don't understand in the
slightest. I need many of these controls for my "human playback" algorithms.

4. Last but not least, I needed a personal project to learn Haskell (I have
not and never will use it for work) so this is fun, and when you consider
how it lets me experiment and use non-standard synthesizers, really quite
practical in the end.

5. Also, I can limit my functionality to what I need. The big programs like
LilyPond need to handle all sorts of instruments and notations. Say,
guitar. That's a whole project in itself. But I'm not using guitar. I'm
only using maybe 20% of the types of symbols and expressive marks that the
big programs handle.

D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151201/317bf252/attachment-0001.html>

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

Message: 5
Date: Tue, 1 Dec 2015 16:12:50 -0800
From: Dan Stromberg <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] More type errors I'm having trouble with
Message-ID:
        <caovkw55ay0n2iaqthhqewbrruofdtkpwmlzxfz27vxrzdkw...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I'm continuing my now-and-then exploration of Haskell.

I'm getting a new crop of type errors that I'm pulling my hair out over.

The errors I'm getting are:

$ make
below cmd output started 2015 Tue Dec 01 04:05:17 PM PST
# --make will go out and find what to build
ghc -Wall --make -o dph dph.hs Split0.hs
[1 of 3] Compiling Split0           ( Split0.hs, Split0.o )
[2 of 3] Compiling Md5s             ( Md5s.hs, Md5s.o )
[3 of 3] Compiling Main             ( dph.hs, dph.o )

dph.hs:13:13:
    Couldn't match type `IO' with `(,) (IO String)'
    Expected type: (IO String, String)
      Actual type: IO String
    In a stmt of a 'do' block: hash <- prefix_md5 filename :: IO String
    In the expression:
      do { hash <- prefix_md5 filename :: IO String;
           (hash, filename) }
    In an equation for `do_prefix_hash':
        do_prefix_hash filename
          = do { hash <- prefix_md5 filename :: IO String;
                 (hash, filename) }

dph.hs:14:6:
    Couldn't match type `[Char]' with `IO String'
    Expected type: IO String
      Actual type: String
    In the expression: hash
    In a stmt of a 'do' block: (hash, filename)
    In the expression:
      do { hash <- prefix_md5 filename :: IO String;
           (hash, filename) }

dph.hs:24:23:
    Couldn't match type `[]' with `IO'
    Expected type: IO (IO String, String)
      Actual type: [(IO String, String)]
    In a stmt of a 'do' block:
      io_hash_tuples <- map do_prefix_hash filenames ::
                          [(IO String, String)]
    In the expression:
      do { buffer <- (hGetContents stdin) :: IO String;
           let filenames = ...;
           io_hash_tuples <- map do_prefix_hash filenames ::
                               [(IO String, String)];
           hash_tuples <- sequence io_hash_tuples :: [(String, String)];
           .... }
    In an equation for `main':
        main
          = do { buffer <- (hGetContents stdin) :: IO String;
                 let filenames = ...;
                 io_hash_tuples <- map do_prefix_hash filenames ::
                                     [(IO String, String)];
                 .... }

dph.hs:25:20:
    Couldn't match type `[a0]' with `(String, String)'
    Expected type: [(String, String)]
      Actual type: [[a0]]
    In the return type of a call of `sequence'
    In a stmt of a 'do' block:
      hash_tuples <- sequence io_hash_tuples :: [(String, String)]
    In the expression:
      do { buffer <- (hGetContents stdin) :: IO String;
           let filenames = ...;
           io_hash_tuples <- map do_prefix_hash filenames ::
                               [(IO String, String)];
           hash_tuples <- sequence io_hash_tuples :: [(String, String)];
           .... }

dph.hs:25:20:
    Couldn't match type `[]' with `IO'
    Expected type: IO (String, String)
      Actual type: [(String, String)]
    In a stmt of a 'do' block:
      hash_tuples <- sequence io_hash_tuples :: [(String, String)]
    In the expression:
      do { buffer <- (hGetContents stdin) :: IO String;
           let filenames = ...;
           io_hash_tuples <- map do_prefix_hash filenames ::
                               [(IO String, String)];
           hash_tuples <- sequence io_hash_tuples :: [(String, String)];
           .... }
    In an equation for `main':
        main
          = do { buffer <- (hGetContents stdin) :: IO String;
                 let filenames = ...;
                 io_hash_tuples <- map do_prefix_hash filenames ::
                                     [(IO String, String)];
                 .... }

dph.hs:25:29:
    Couldn't match expected type `[[a0]]'
                with actual type `(IO String, String)'
    In the first argument of `sequence', namely `io_hash_tuples'
    In a stmt of a 'do' block:
      hash_tuples <- sequence io_hash_tuples :: [(String, String)]
    In the expression:
      do { buffer <- (hGetContents stdin) :: IO String;
           let filenames = ...;
           io_hash_tuples <- map do_prefix_hash filenames ::
                               [(IO String, String)];
           hash_tuples <- sequence io_hash_tuples :: [(String, String)];
           .... }

dph.hs:26:39:
    Couldn't match expected type `[(String, String)]'
                with actual type `(String, String)'
    In the second argument of `map', namely `hash_tuples'
    In the expression: map tuple_to_string hash_tuples :: [String]
    In an equation for `strings':
        strings = map tuple_to_string hash_tuples :: [String]
make: *** [dph] Error 1
above cmd output done    2015 Tue Dec 01 04:05:18 PM PST


dph.hs looks like:
import Md5s
import Split0
import System.IO

get_filenames :: String -> [String]
get_filenames buffer = do
    -- Let's hope this doesn't give locale-related roundtrip problems.
    Split0.split0 '\0' buffer :: [String]

do_prefix_hash :: String -> (IO String, String)
do_prefix_hash filename = do
    hash <- Md5s.prefix_md5 filename :: (IO String)
    (hash, filename)

tuple_to_string :: (String, String) -> String
tuple_to_string (first, second) = do
    (show first) ++ " " ++ (show second)

main :: IO ()
main = do
    buffer <- (System.IO.hGetContents System.IO.stdin) :: IO String
    let filenames = (get_filenames buffer) :: [String]
    io_hash_tuples <- map do_prefix_hash filenames :: [(IO String, String)]
    hash_tuples <- sequence io_hash_tuples :: [(String, String)]
    let strings = map tuple_to_string hash_tuples :: [String]
    mapM_ putStrLn strings


And Md5s.hs looks like:
module Md5s where

import qualified System.IO
import qualified Text.Printf
-- cabal install cryptohash
import qualified Crypto.Hash.MD5
import qualified Data.ByteString
import qualified Data.ByteString.Lazy

-- 
http://stackoverflow.com/questions/10099921/efficiently-turn-a-bytestring-into-a-hex-representation
byte_string_to_hex :: Data.ByteString.ByteString -> String
byte_string_to_hex = concatMap (Text.Printf.printf "%02x") .
Data.ByteString.unpack

prefix_md5 :: String -> IO String
prefix_md5 filename = do
    let prefix_length = 1024
    file <- System.IO.openBinaryFile filename System.IO.ReadMode :: IO
System.IO.Handle
    data_read <- Data.ByteString.hGet file prefix_length :: IO
Data.ByteString.ByteString
    _ <- System.IO.hClose file
    let hasher = Crypto.Hash.MD5.init :: Crypto.Hash.MD5.Ctx
    let hasher2 = Crypto.Hash.MD5.update hasher data_read ::
Crypto.Hash.MD5.Ctx
    let binary_digest = Crypto.Hash.MD5.finalize hasher2 ::
Data.ByteString.ByteString
    let hex_digest = byte_string_to_hex binary_digest :: String
    return hex_digest :: IO String

full_md5 :: String -> IO String
full_md5 filename = do
    file <- System.IO.openBinaryFile filename System.IO.ReadMode :: IO
System.IO.Handle
    data_read <- Data.ByteString.Lazy.hGetContents file :: IO
Data.ByteString.Lazy.ByteString
    let binary_digest = Crypto.Hash.MD5.hashlazy data_read ::
Data.ByteString.ByteString
    let hex_digest = byte_string_to_hex binary_digest :: String
    -- Does this get closed for us later?
    -- strace shows the file getting closed without our explicit close.
    -- _ <- System.IO.hClose file
    return hex_digest :: IO String


It might be easier to view these at
http://stromberg.dnsalias.org/svn/equivalence-classes/trunk/equivs3-haskell/
, so the line numbers are precise.

What is the deal?

Can anyone tell me what should be running through my head to fix this kind
of problem on my own in the future?

Thanks!

-- 
Dan Stromberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151201/069dfcc4/attachment.html>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 90, Issue 2
****************************************

Reply via email to