haskore 0.1 → 0.1.0.1
raw patch · 4 files changed
+77/−9 lines, 4 filesdep ~base
Dependency ranges changed: base
Files
- Makefile +1/−1
- haskore.cabal +7/−6
- src/Haskore/General/LetRec.hs +67/−0
- src/Haskore/Interface/MIDI/Write.lhs +2/−2
Makefile view
@@ -63,7 +63,7 @@ # exclude installed versions of Haskore, because we want to use the local one HUGS_PACKAGE_PATH = \- {Hugs}/libraries:{Hugs}/packages/*:$(subst $(space),$(colon),$(patsubst %,/usr/local/lib/hugs/packages/%,event-list midi markov-chain non-negative special-functors data-accessor transformers explicit-exception binary utility-ht))+ {Hugs}/libraries:{Hugs}/packages/*:$(subst $(space),$(colon),$(patsubst %,/usr/local/lib/hugs/packages/%,event-list midi markov-chain non-negative special-functors data-accessor transformers monoid-transformer explicit-exception binary utility-ht)) # $(subst $(space),$(colon),$(patsubst %,{Hugs}/packages/%,event-list midi markov-chain non-negative record-access))
haskore.cabal view
@@ -1,5 +1,5 @@ Name: haskore-Version: 0.1+Version: 0.1.0.1 License: GPL License-File: LICENSE Author: Paul Hudak <paul.hudak@yale.edu>, Henning Thielemann@@ -11,7 +11,7 @@ Description: Compose music using programming features. Output in MIDI, CSound, SuperCollider or as an audio signal.-Tested-With: GHC==6.4.1, GHC==6.8.2, Hugs==2006.9+Tested-With: GHC==6.4.1, GHC==6.8.2, GHC==6.10.4, Hugs==2006.9 Cabal-Version: >=1.6 Build-Type: Simple @@ -26,12 +26,12 @@ Source-Repository head type: darcs- location: http://darcs.haskell.org/haskore/+ location: http://code.haskell.org/haskore/revised/core Source-Repository this type: darcs- location: http://darcs.haskell.org/haskore/- tag: 0.1+ location: http://code.haskell.org/haskore/revised/core+ tag: 0.1.0.1 Flag splitBase description: Choose the new smaller, split-up base package.@@ -55,7 +55,7 @@ If flag(splitBase) Build-Depends:- base >=3,+ base >=3 && <6, array >=0.1 && <1.0, containers >=0.1 && <1.0, random >=1.0 && <2.0,@@ -153,6 +153,7 @@ Haskore.General.LoopTreeTaggedGen, Haskore.General.GraphRecursiveGen, Haskore.General.GraphTaggedGen,+ Haskore.General.LetRec, Haskore.General.Map, Haskore.General.TagDictionary, Haskore.General.Utility
+ src/Haskore/General/LetRec.hs view
@@ -0,0 +1,67 @@+module Haskore.General.LetRec where++import Data.Tuple.HT (mapFst, mapSnd, )+import qualified Data.Map as Map+++data Expr =+ Const String+ | Append Expr Expr+ | Var Var+ deriving (Show)++type Var = Int+type Count = Int+++knot ::+ (Count, ([Expr], (Expr, a)) -> ([Expr], (Expr, b))) ->+ (Count, ([Expr], a) -> ([Expr], b))+knot (count, f) =+ (succ count,+ \(equs0, a) ->+ let (equs1, (rhs, b)) = f (equs0, (Var count, a))+ in (rhs : equs1, b))++beginKnot ::+ (a -> b) ->+ (Count, ([Expr], a) -> ([Expr], b))+beginKnot f =+ (0, mapSnd f)++endKnot ::+ (Count, ([Expr], a) -> ([Expr], b)) ->+ (a -> ([Expr], b))+endKnot f a = snd f ([], a)+++exampleLet ::+ (Expr, (Expr, ())) ->+ (Expr, (Expr, Expr))+exampleLet (a,(b,())) =+ (Append (Const "ab") b,+ (Append (Const "c") a,+ a))++{-+Maybe we can replace manual repeated application of 'knot'+by a type class method.+-}+exampleEqus :: ([Expr], Expr)+exampleEqus =+ mapFst reverse $+ endKnot (knot (knot (beginKnot exampleLet))) ()++exampleResult :: String+exampleResult =+ let mapExpr = Map.fromAscList $ zip [0..] $ fst exampleEqus+ resolve x =+ case x of+ Const str -> str+ Append a b ->+ resolve a ++ resolve b+ Var n -> Map.findWithDefault+ (error $ "unknown variable id " ++ show n ++ " - bug in 'knot'?")+ n mapRes+ mapRes = fmap resolve mapExpr+ in resolve $ snd exampleEqus
src/Haskore/Interface/MIDI/Write.lhs view
@@ -405,11 +405,11 @@ \end{haskelllisting} -*****+% *** The MIDI volume handling is still missing. One cannot express the Volume in terms of the velocity! Thus we need some new event constructor for changed controller values.-*****+% *** \begin{haskelllisting}