lhe (empty) → 0.1
raw patch · 4 files changed
+142/−0 lines, 4 filesdep +HaXmldep +haskell2010setup-changed
Dependencies added: HaXml, haskell2010
Files
- LICENSE +19/−0
- Setup.hs +2/−0
- Text/LHE.hs +60/−0
- lhe.cabal +61/−0
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2011 Scott Lawrence <bytbox@gmail.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Text/LHE.hs view
@@ -0,0 +1,60 @@+module Text.LHE (+ version,++ parseEventFile,+ parseEvents,++ parseRawEventFile,+ parseRawEvents,++ Event(..),+ RawEvent(..),+) where++import Text.XML.HaXml.Parse (xmlParse)+import Text.XML.HaXml.Types (Document(..), Element(..), Content(..), QName(..))++data Init = Init+ deriving (Eq, Show, Read)++data Event = Event [Double] [[Double]]+ deriving (Eq, Show, Read)++data RawEvent = RawEvent [Double] [[Double]]+ deriving (Eq, Show, Read)++version :: String+version = "0.1"++parseEventFile :: String -> IO [Event]+parseEventFile fname = do+ readFile fname >>= return . parseEvents fname++parseEvents :: String -> String -> [Event]+parseEvents fname dat =+ let re = parseRawEvents fname dat in+ []++parseRawEventFile :: String -> IO [RawEvent]+parseRawEventFile fname = do+ readFile fname >>= return . parseRawEvents fname++parseRawEvents :: String -> String -> [RawEvent]+parseRawEvents fname dat =+ let Document _ _ (Elem eName _ eList) _ = xmlParse fname dat in+ map (getRawEvent . getElem) $ filter isEvent eList+ where+ isEvent (CElem (Elem (N "event") _ _) _) = True+ isEvent _ = False+ isCString (CString _ _ _) = True+ isCString _ = False+ parseLine = map parseDouble . words+ getElem (CElem (Elem _ _ c) _) = head $ filter isCString c+ getRawEvent (CString _ eStr _) =+ let eLines = filter (\x -> length x > 2) $ lines eStr in+ RawEvent (parseLine $ head eLines) (map parseLine $ tail eLines)+ getRawEvent _ = RawEvent [] []++parseDouble :: String -> Double+parseDouble = read . reverse . dropWhile (=='.') . reverse+
+ lhe.cabal view
@@ -0,0 +1,61 @@+-- LHE.cabal auto-generated by cabal init. For additional options, see+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.+-- The name of the package.+Name: lhe++-- The package version. See the Haskell package versioning policy+-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for+-- standards guiding when and how versions should be incremented.+Version: 0.1++-- A short (one-line) description of the package.+Synopsis: Parse for Les-Houches event files++-- A longer description of the package.+Description: This package implements a parser for the Les-Houches event file format as described in hep-ph/0609017++-- The license under which the package is released.+License: MIT++-- The file containing the license text.+License-file: LICENSE++-- The package author(s).+Author: Scott Lawrence++-- An email address to which users can send suggestions, bug reports,+-- and patches.+Maintainer: bytbox@gmail.com++-- A copyright notice.+-- Copyright: ++Category: Text++Build-type: Simple++-- Extra files to be distributed with the package, such as examples or+-- a README.+-- Extra-source-files: ++-- Constraint on the version of Cabal needed to build this package.+Cabal-version: >=1.6+++Library+ -- Modules exported by the library.+ Exposed-modules: Text.LHE+ + -- Packages needed in order to build this package.+ Build-depends: haskell2010 >= 1.0 , HaXml >= 1.22+ + -- Modules not exported by this package.+ -- Other-modules: + + -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.+ -- Build-tools: + +source-repository head+ type: git+ location: https://bytbox@github.com/bytbox/lhe.hs.git+