Wondering if I could get some suggestions for coding this problem.
A musical document (or score) consists primarily of a list of measures. A
measure consists primarily of lists of items. We'll consider only one
kind of item: a note. Items have a location within the measure. A note's
location
Henning Thielemann wrote:
On Sun, 4 Jul 2010, Michael Mossey wrote:
I can solve a simpler problem which is
computeSoundedEnd :: Item - [Item] - Loc
computeSoundedEnd firstNote notes = compSndEnd (pitch firstNote) notes
You will certainly not be able to make use of foldl or foldr, but you
Serguey Zefirov wrote:
The thing that is hard for me to understand is how, in a functional
paradigm, to update the entire Doc by chasing down every tie and making
all necessary updates.
This looks like one of graph algorithms.
Notes are nodes, ties are arcs. Measures, etc are parts of node
Hi Stephen,
Thanks for thinking about this. The problem, though, is that notes can
overlap in time. MusicXML solves this by having not just Note and Rest, but
Backup and Forward which indicate the current position should be moved
before interpreting the following data. I'm trying to make it
Henning Thielemann wrote:
On Sun, 4 Jul 2010, Michael Mossey wrote:
Henning Thielemann wrote:
On Sun, 4 Jul 2010, Michael Mossey wrote:
I can solve a simpler problem which is
computeSoundedEnd :: Item - [Item] - Loc
computeSoundedEnd firstNote notes = compSndEnd (pitch firstNote) notes
erik flister wrote:
ties are a presentation-level issue, the underlying (sound)
representation is a single note. i suggest
Doc = [Note]
where Notes have fields for their measure location and duration. then
there's no issue with overlapping notes, and start/end times are easy to
erik flister wrote:
I am dealing with ties because I am converting a MusicXML document
into a more natural form for my purposes. The initial form of the
document will have tied notes (as it comes that way from MusicXML),
and I want to convert that into a form that makes it
erik flister wrote:
That's what I want to do. I'm asking about a good way to write the
algorithm that traverses the notes and reconstructs the document
with the correct duration in each note.
why isn't this as simple as
Erik,
I'm learning from your code examples, but I
erik flister wrote:
Michael Mossey wrote:
Regarding my use of Rational, it's because I'm representing
*notated* durations or positions in time, which are always fractions
of integers. Suppose I give the command to my program to play via
midi everything from bar 1 beat 1
(I asked this question on the logical email list to ask, haskell-mode, but
got no reply, so I'm hoping someone here might know the answer.)
I tried to use tags with emacs.
I ran :etags in ghci, then tried to use C-c M-. inside Emacs
to find the definition of a symbol. It reported no source
I'm fairly beginnerish to Haskell, and come from OO. I have a complaint
about Haskell, but I think I found a good solution. Any suggestions welcome.
I have RSI and like to minimize typing. The use of classes as name
spaces helps to do that. Also I can use some Emacs abbreviation magic
easily
Michael Mossey wrote:
incrCursor :: State PlayState ()
incrCursor =
cur - gets playState_cursor
len - gets playState_len
let newCur = min (cur+1) (len-1)
modify (playState_update_cursor newCur)
Whoa, I just realized I'm not using 'modify' to full advantage. This can
be written
Neil Brown wrote:
On 08/07/10 09:08, Michael Mossey wrote:
data PlayState = PlayState
{ playState_cursor :: Int
, playState_verts :: [Loc]
, playState_len :: Int
, playState_doc :: MusDoc
}
Notice how often
Daniel Fischer wrote:
If f has the appropriate type and the base case is f 0 = 0,
module Memo where
import Data.Array
f :: (Integral a, Ord a, Ix a) = a - a
f n = memo ! n
where
memo = array (0,n) $ (0,0) :
[(i, max i (memo!(i `quot` 2) + memo!(i `quot` 3)
PM, Michael Mossey wrote:
Daniel Fischer wrote:
If f has the appropriate type and the base case is f 0 = 0,
module Memo where
import Data.Array
f :: (Integral a, Ord a, Ix a) = a - a
f n = memo ! n
where
memo = array (0,n) $ (0,0) :[(i, max i (memo!(i
`quot` 2) + memo!(i
I notice in algebraic data defined with named fields, you can use the
same name inside different constructors and then apply it to any data of
that type.
data Vehicle = Car { ident :: String, wheel :: Circle }
| Plane { ident :: String, stick :: Line }
f :: [Vehicle] - [String]
f
I'm looking for a hint to write the following code with less redundancy. I
have a constructor called BoxBounds, and I want to make one with random
values.
randomBox :: IO BoxBounds
randomBox = do
x - getStdRandom (randomR (-10,10))
y - getStdRandom (randomR (-70,70))
t - getStdRandom
Duncan Coutts wrote:
On Sun, 2009-10-04 at 02:52 -0700, Michael Mossey wrote:
I'm looking for a hint to write the following code with less redundancy. I
have a constructor called BoxBounds, and I want to make one with random
values.
randomBox :: IO BoxBounds
randomBox = do
x - getStdRandom
Eugene Kirpichov wrote:
[x,y,t,b,l,r] - mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...]
return (BoxBounds ...)
Thanks.
I'm curious about the idea of pattern matching in do-statements that can
fail. This particular pattern cannot fail. I read that the fail function
was introduced
If I understand correctly, this works because IO is an instance of
Applicative, correct?
I wonder if any of the random monads are instances of Applicative.
Felipe Lessa wrote:
On Sun, Oct 04, 2009 at 01:55:11PM +0400, Eugene Kirpichov wrote:
[x,y,t,b,l,r] - mapM (getStdRandom . randomR)
If I have a list containing the arguments I want to give to a function, is
there a general way to supply those arguments in a compact syntax?
In other words, I could have
args = [1,2,3]
f x y z = ...
I would write
t = f (args!!0) (args!!1) (args!!2)
but there may be a neater, more general
My thread about randomness got hijacked so I need to restate my remaining
question here. Is it acceptable to write pure routines that use but do not
return generators, and then call several of them from an IO monad with a
generator obtained by several calls to newStdGen?
shuffle :: RandomGen
Luke Palmer wrote:
On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey m...@alumni.caltech.edu wrote:
My thread about randomness got hijacked so I need to restate my remaining
question here. Is it acceptable to write pure routines that use but do not
return generators, and then call several
In Test.QuickCheck, the type of 'generate' is
generate :: Int - StdGen - Gen a - a
I can't find docs that explain what the Int does. Some docs are here:
http://www.haskell.org/ghc/docs/latest/html/libraries/QuickCheck/Test-QuickCheck.html
___
I wrote some code to model the keystroke-to-keystroke delay in a person
typing, with pseudorandomness. There are two kinds of delays.. one is a
very small delay as the person reaches for a new key (call this 'reach'
delays), the other is a larger delay that represents a pause to think or
to take a
I'm trying to learn how to use randomness in Haskell and it seems very
non-straightforward and complex. I could do a lot of things using 'split'
from System.Random, but apparently it's broken. There is the statistics
package here:
http://hackage.haskell.org/package/statistics
Is this a
I'm looking at Control.Monad.Random which provides the Rand monad. I would
like to know how to use this for generating multiple infinite series, while
trusting that the implementation never uses split behind the scenes.
(Note: I'm on Windows XP, and there appears to be a bug in getStdGen. It
Can someone give me an example of Sound.PortMidi use? I'm having trouble.
This program has bugs---makes sound only intermittently, and seems to have
set up some kind of loop that is sending midi messages continuously even
after terminating the program:
import Sound.PortMidi
import Foreign.C
The examples in the error handling chapter (19) of RWH don't run under
GHC 6.10.
For instance, an example might be
main = handle (\_ - putStrLn error) (print $ 5 `div` 0)
Trying to load this results in amigous type variable 'e' in the
constraint: 'Exception e' arising from a use of 'handle'
Apparently the old exception library had convenience functions like
'arithExceptions' that could be used with 'handleJust'.
handleJust arithExceptions handler thing
With the new module you can write something like this (I determined this
from experimentation):
arithExceptionTester ::
Before I ask my main question, incidentally has anyone noticed that the
GHCI prompt, on Windows XP, now has auto-completion! (since 6.10) Awesome!
I'm trying to install System.Console.Readline on Windows XP. I need to have
GNU readline installed first, which I did (by multiple methods). But
I have some very simple regex-matching needs, and Text.Regex.Posix will
work fine, EXCEPT I need to match multi-line patterns, and/or find all
occurrences of text that may occur several times on different lines. So I
need to turn on some kind of flag. Can someone show me how to do that? I
have
kenny lu wrote:
Hi Michael,
Could you give an example of what patterns you want to write?
Regards,
Kenny
Something like
text = 11\n abcd \n22
answer = text =~ 11.*22 :: various possibilities
and have it find the entire string. The default behavior is to stop
matching when it encounters
I'm pretty new to Haskell so I don't know what kind of data structure I
should use for the following problem. Some kind of arrays, I guess.
One data item, called OrientedPCSet (oriented pitch class set, a musical
term) will represent a set whose members are from the range of integers 0
to 11.
Hi Stephen,
I will need a function that computes prime (normal?) form, of course, and
it is just begging to be memoized. I wonder if that is possible with
Data.Set, or whether it would be much faster using the bit vector
representation?
Thanks,
Mike
Stephen Tetley wrote:
Postscript...
Can someone tell me if this is correct. I'm guessing that if I represent
two sets of integers by Word32 (where ith bit set means i is in the set),
then an algorithm to determine if x is a subset of y would go something
like
(y - x) == (y `exclusiveOr` x)
I'm fairly new to Haskell, and starting to write some big projects.
Previously I used OO exclusively, mostly Python. I really miss the
namespace capabilities... a class can have a lot of generic method names
which may be identical for several different classes because there is no
ambiguity.
First of all, thanks for the ideas, everyone. I think I'm starting to get
the usefulness of type classes.
With regard to your question, Eugene, you are probably right. In fact my
rough draft of this code from four months ago used a Map with time as the
key (of type Rational). I was trying to
Thanks for the reply. Was there something specific you were referring to,
or just the idea that he wrote Haskore? Haskore is not very closely related
to what I'm trying to do. I believe he has a CSound back end for Haskore,
but it is in a rough state and not closely related to what I'm trying
Daniel Fischer wrote:
getNumber :: String - AssignedNumbers - (Int,AssignedNumbers)
Yeah, that screams State Monad.
Hi, thanks for all the advice.
I was hoping my AssignedNumbers class would be useful with many data
structures. In other words I would have
data State1 = State1 { a ::
Stephen Tetley wrote:
Hi Mike
There used to be some slides available commenting on Haskore's CSound
interface. But they seem to have vanished (I have a copy rendered to
pdf when they were available). Like all slide presentations there's a
lot of reading between the lines to get a good picture
like CSound that things
get ugly. However, I have a new idea. Stay tuned.
-Mike
Gregg Reynolds wrote:
On Tue, Dec 1, 2009 at 7:55 PM, Michael Mossey m...@alumni.caltech.edu
mailto:m...@alumni.caltech.edu wrote:
Thanks for the reply. Was there something specific you were referring
Michael P Mossey wrote:
Perhaps someone could either (1) help me do what I'm trying to do, or
(2) show me a better way.
I have a problem that is very state-ful and I keep thinking of it as OO,
which is driving me crazy. Haskell is several times harder to use than
Python in this instance,
When I started to study Haskell, I was surprised that so much emphasis was
placed on simple things. Monads were introduced to me as basically a
wrapper, and a bind function that unwrapped something and wrapped something
else back up again. I didn't understand what the fuss was about. Later I
Robert Greayer wrote:
But the discussion is about a coding standard -- surely if I claimed to like to
have 4 windows side by side, that wouldn't be a good reason to reduce the
standard
to 40 columns? Being able to read one line 'at a glance' seems to me to be
improved if that line contains
I'm intermediate-level myself so I hesitate to say something wrong, but I'll go
ahead and point out the obvious.
applebiz89 wrote:
Hey thanks, that was really helpful actually. I know it must be annoying for
you, and im sorry but ive done what you said, try and compile it to see if
it does and
This is not directly related to Haskell, but it's a thought that occurred
to me after exposure to the Haskell community.
I've spent most of the past 15 years doing scientific programming. The lead
software architect and software managers are using good software
engineering practice, though
Conal Elliott wrote:
Hi Michael,
I'm going to hazard a guess. Please let me know how accurate it is.
Conal,
I think you described this situation well. You must know this kind of
person---I'm sure there's more than one in the world!
When asked to justify his design, the lead software
I want to choose a GUI library for my project. Some background: I'm a
beginner to functional programming and have been working through Haskell
books for a few months now. I'm not just learning Haskell for s**ts and
giggles; my purpose is to write music-composition-related code; in
particular,
surface?
Thanks,
Mike
Jean-Denis Koeck wrote:
I began writing a commercial app with a GUI using Gtk2hs,
but it looked ugly on Windows. I'm switching to WxHaskell.
2009/8/29 Michael Mossey m...@alumni.caltech.edu
mailto:m...@alumni.caltech.edu
I want to choose a GUI library for my
Jason Dagit wrote:
I've never used it myself, but if you're going to be drawing a lot
perhaps cairo is right for you?
http://cairographics.org/hscairo/
I suspect you'll have to be self-taught here. Gtk2Hs and WxHaskell
are probably the most mature gui libs for Haskell. Yet with either
one
Dan Weston wrote:
One simple solution is to leave the state in Qt.
As of Qt 4.2, in C++ you can use
bool QObject::setProperty(const char * name, const QVariant value)
QVariant QObject::property(const char * name) const
to set and get properties on any QObject (hence any QWidget).
Duncan Coutts wrote:
On Wed, 2009-09-09 at 18:29 -0700, Michael P Mossey wrote:
I'm trying to learn qtHaskell. I realize few people on this list know anything
about qtHaskell, but I have a question that probably relates to all GUIs as
implemented in Haskell. I just need a hint that could
I'm working on a GUI application in qtHaskell, and I have a bit of a bind.
Using ghci, it launches quickly but runs slowly. On the other hand,
compiling (mainly linking) takes a while---several minutes. The truth is
that I can compile it much faster if I selectively import the needed
modules,
I have a combinatorial search problem that requires a
running lower bound to be tracked in order to prune the search. I have enough
Haskell experience to know how to do a combinatorial search, for example with
list compresions or the list monad, but I don't know how to keep a running
lower
I made some mistakes in editing this code before posting it. I wrote
BoxBounds in a couple places when I meant Box. Also made calls to boxesSep'
when I meant boxesSep2'. Hopefully should all be obvious from context.
Michael Mossey wrote:
I have a combinatorial search problem that requires
bound.) The
maximum of all these lower bounds in the minimum needed separation.
-Mike
Chung-chieh Shan wrote:
Michael Mossey m...@alumni.caltech.edu wrote in article
3942.75.50.175.130.1253997756.squir...@mail.alumni.caltech.edu in
gmane.comp.lang.haskell.cafe:
The problem is to determine
Iain Barnett wrote:
So, if I was trying to come up with a solution to a problem that
possibly has multiple solutions, like building an engine for a car, I
would do better if I hadn't seen a (well crafted) working engine by
someone else than if I had?
If effort is there, then give me the
This is a beginners question, which I have posted to
beginn...@haskell.org several times, but because I have gotten no
answer, I thought I would try the cafe.
I'm working through the School of Expression book, and I would like to
install the code that comes with the book somewhere. Right now
, though, in how one installs packages or modules
so they don't need to be on the path specified by -i. I notice there is
a file called 'package.conf', which seems related to this.
Martijn van Steenbergen wrote:
Michael Mossey wrote:
I tried using the -i options to ghc and ghci, but to no avail
the end of the score (2) reached the
right edge of the page. There might be a way to simplify the loop or fold so
that these concerns look more unified.
-Mike
PS a question below:
Heinrich Apfelmus wrote:
Michael Mossey wrote:
Heinrich Apfelmus wrote:
Can you elaborate on what exactly
I'm thinking of writing a parser to load files that my customers have created. I'm a
software requirements engineer; the data consists of the customers' thoughts in
response to the latest release of the requirements doc. In fact, the files will
probably be copies of the requirements doc itself,
Robin Green wrote:
On Wed, 15 Apr 2009 23:31:50 -0700
Michael Mossey m...@alumni.caltech.edu wrote:
I was thinking that it might be useful to have a Google-like do you
mean this? feature. If the field name is //customer=, then the
parser might recognize a huge list of variants
like //ustomer
Here's what I've got so far.
-- Text is considered everything up to //. However, the problem
-- is that this consumes the //.
parseText = manyTill anyChar (try (string //))
-- Because the // is already consumed, parseKeyword just grabs
-- the available letters.
parseKeyword :: Parser String
My confusion is that text is by definition followed by // or eof.
minh thu wrote:
You can use 'notFollowedBy' (probably with 'many1' and 'try').
Something like (untested):
notFollowedBy (try $ string //)
Thu
2009/4/17 Michael Mossey m...@alumni.caltech.edu:
Here's what I've got so far
Jason Dusek wrote:
2009/04/17 minh thu not...@gmail.com:
2009/04/17 Michael Mossey m...@alumni.caltech.edu:
I wonder how I can get the manyTill to be happy with eof
before finding the //? I tried
parseText = manyTill anyChar (try (string //) | eof)
but got a type error.
You can use
66 matches
Mail list logo