diff --git a/COPYING b/COPYING
new file mode 100644
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,26 @@
+
+Copyright (c) 2013, Hans Höglund
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of the <organization> nor the
+      names of its contributors may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,4 @@
+#! /usr/bin/env runhaskell
+
+> import Distribution.Simple
+> main = defaultMain
diff --git a/abcnotation.cabal b/abcnotation.cabal
new file mode 100644
--- /dev/null
+++ b/abcnotation.cabal
@@ -0,0 +1,32 @@
+
+name:               abcnotation
+version:            0.5
+cabal-version:      >= 1.2
+author:             Hans Hoglund
+maintainer:         Hans Hoglund
+license:            BSD3
+license-file:       COPYING
+synopsis:           Haskell representation and parser for ABC notation.
+category:           Music
+tested-with:        GHC
+build-type:         Simple
+
+description: 
+    This package contains a Haskell representation and parser for ABC notation. 
+    .
+    ABC notation is a text-based music notation system designed to be comprehensible by both people and 
+    computers. For more information see <http://abcnotation.com>.
+    .
+    Based on the 2.1 standard.
+
+library                    
+    build-depends: 
+        base >= 4 && < 5,
+        semigroups,
+        prettify,
+        network,
+        parsec
+    hs-source-dirs: src
+    exposed-modules:
+        Music.Abc
+        Music.Abc.Parser
diff --git a/src/Music/Abc.hs b/src/Music/Abc.hs
new file mode 100644
--- /dev/null
+++ b/src/Music/Abc.hs
@@ -0,0 +1,292 @@
+
+{-# LANGUAGE TypeOperators, GeneralizedNewtypeDeriving #-}
+
+-------------------------------------------------------------------------------------
+-- |
+-- Copyright   : (c) Hans Hoglund 2012
+--
+-- License     : BSD-style
+--
+-- Maintainer  : hans@hanshoglund.se
+-- Stability   : experimental
+-- Portability : portable
+--
+-- A Haskell representation and parser for ABC notation. Based on the 2.1 standard. 
+-- 
+-- For more information see <http://abcnotation.com>.
+--
+-------------------------------------------------------------------------------------
+
+module Music.Abc (
+        -- * Abc format
+        -- ** Files
+        AbcFile(..),     
+
+        -- *** File header
+        FileHeader(..),
+        Element(..),
+
+        -- ** Tunes
+        AbcTune(..),
+        TuneHeader(..), 
+        TuneBody(..), 
+
+        -- * Music
+        Music(..),
+        
+        -- ** Note stack
+        Note(..),
+
+        DecorationT(..),
+        SlurT(..),
+        BeamT(..),
+        GraceT(..),
+        TupletT(..),
+        DurationT(..),
+        RestT(..),
+        (:|:),
+        
+        -- * Basic types
+        -- ** Time
+        Duration(..),
+
+        -- ** Pitch
+        PitchClass(..),
+        Accidental(..),
+        Octave(..),
+        Pitch(..),
+
+        -- ** Decorations (articulation, dynamics etc)
+        Decoration(..),
+
+        -- ** Structure
+        Barline(..),
+        MultiRest(..),
+
+        -- ** Information etc
+        Information(..),
+        Directive(..),
+
+        -- * Import and export
+        readAbc,
+        showAbc
+  ) where
+
+import Network.URI (URI)
+
+-- | A full ABC file (2.2).
+data AbcFile
+    = AbcFile
+        (Maybe String)
+        (Maybe FileHeader)
+        [Element]
+
+-- | File header (2.2.2).
+data FileHeader
+    = FileHeader 
+        [Information] 
+        [Directive]
+    deriving (Eq, Ord, Show)
+
+-- | Either a tune, free text or typeset text (2.2.3).
+data Element
+    = Tune
+        AbcTune                         -- ^ An Abc tune.
+    | FreeText
+        String                          -- ^ Free text (2.2.3).
+    | TypesetText
+        String                          -- ^ Typeset text (2.2.3).
+    deriving (Eq, Ord, Show)
+
+data AbcTune 
+    = AbcTune 
+        TuneHeader 
+        TuneBody
+    deriving (Eq, Ord, Show)
+
+-- TODO verify X, T and K fields
+data TuneHeader 
+    = TuneHeader 
+        [Information]
+    deriving (Eq, Ord, Show)
+
+type TuneBody = [Music]
+
+-- One line of music code.
+data Music 
+    = Music [Note :|: MultiRest :|: Barline :|: ()]
+    deriving (Eq, Ord, Show)
+
+newtype MultiRest = MultiRest { getMultiRest :: Int }
+    deriving (Eq, Ord, Show)
+
+type Note = DecorationT (SlurT (BeamT (GraceT (TupletT (DurationT (RestT Pitch))))))
+
+type DecorationT a  = ([Decoration], a)
+type SlurT a        = (Bool, a, Bool)
+type BeamT a        = (Bool, a, Bool)
+type GraceT a       = (Bool, a)
+type TupletT a      = (Duration, a)
+type DurationT a    = (a, Duration)
+type RestT a        = Maybe (Maybe a) -- invisible/visible
+
+data Decoration
+    = Trill                   -- "tr" (trill mark)
+    | TrillBegin              -- start of an extended trill
+    | TrillEnd                -- end of an extended trill
+    | Lowermordent            -- short squiggle with a vertical line through it
+    | Uppermordent            -- short squiggle
+    | Roll                    -- a roll mark (arc) as used in Irish music
+    | Turn                    -- a turn mark (also known as gruppetto)
+    | Turnx                   -- a turn mark with a line through it
+    | Invertedturn            -- an inverted turn mark
+    | Invertedturnx           -- an inverted turn mark with a line through it
+    | Arpeggio                -- vertical squiggle
+    | Accent                  -- accent mark
+    | Fermata Bool            -- fermata or hold (arc above dot), inverted?
+    | Tenuto                  -- horizontal line to indicate holding note for full duration
+    | Fingering Int           -- fingerings
+    | Plus                    -- left-hand pizzicato, or rasp for French horns
+    | Snap                    -- snap-pizzicato mark, visually similar to !thumb!
+    | Slide                   -- slide up to a note, visually similar to a half slur
+    | Wedge                   -- small filled-in wedge mark
+    | Upbow                   -- V mark
+    | Downbow                 -- squared n mark
+    | Open                    -- small circle above note indicating open string or harmonic
+    | Thumb                   -- cello thumb symbol
+    | Breath                  -- a breath mark (apostrophe-like) after note
+    -- !pppp! !ppp! !pp! !p!  dynamics marks
+    -- !mp! !mf! !f! !ff!     more dynamics marks
+    -- !fff! !ffff! !sfz!     more dynamics marks
+    | Crescendo               -- start of a crescendo mark
+    | EndCrescendo            -- end of a crescendo mark, placed after the last note
+    | Diminuendo              -- start of a diminuendo mark
+    | EndDiminuendo           -- end of a diminuendo mark, placed after the last note
+    | Segno                   -- ornate s-like symbols separated by a diagonal line
+    | Coda                    -- a ring with a cross in it
+    | DaSegno                 -- the letters D.S. (=Da Segno)
+    | DaCapo                  -- the letters D.C. (=either Da Coda or Da Capo)
+    | Dacoda                  -- the word "Da" followed by a Coda sign
+    | Fine                    -- the word "fine"
+    | Shortphrase             -- vertical line on the upper part of the staff
+    | Mediumphrase            -- same, but extending down to the centre line
+    | Longphrase              -- same, but extending 3/4 of the way down
+    deriving (Eq, Ord, Show)
+
+
+-- Base types
+
+newtype Duration = Duration { getDuration :: Rational }
+    deriving (Eq, Ord, Show, Enum, Num, Real, Fractional, RealFrac)
+
+data PitchClass = C | D | E | F | G | A | B
+    deriving (Eq, Ord, Show, Enum, Bounded)
+
+data Accidental = DoubleFlat | Flat | Natural | Sharp | DoubleSharp
+    deriving (Eq, Ord, Show, Enum, Bounded)
+
+newtype Octave = Octave { getOctave :: Int }
+    deriving (Eq, Ord, Show, Enum, Num, Real, Integral)
+
+newtype Pitch = Pitch { getPitch :: (PitchClass, Accidental, Octave) }
+    deriving (Eq, Ord, Show)
+
+data StemDirection = Up | Down
+    deriving (Eq, Ord, Show, Enum, Bounded)
+
+data Clef = NoClef | Treble | Alto | Tenor | Bass | Perc
+    deriving (Eq, Ord, Show, Enum, Bounded)
+
+-- | Barline, including special barlines and repeats.
+data Barline
+    = Barline
+    | DoubleBarline Bool Bool   -- thick? thick?
+    | Repeat Int Bool Bool      -- times end? begin?
+    | DottedBarline Barline
+    | InvisibleBarline Barline
+    deriving (Eq, Ord, Show)
+
+-- TODO add elements
+data Information
+    = Area String
+    | Book String
+    | Composer String
+    | Discography String
+    | FileUrl String URI
+    | Group String
+    | History String
+
+    | Instruction Directive
+    | Key Key
+    | UnitNoteLength Duration
+
+    | Meter Meter
+    -- Macros not supported
+    | Notes String
+    | Origin String
+    | Parts -- TODO
+
+    | Tempo Tempo
+    | Rhythm String -- Polska, marsch etc.
+    -- Remarks are discarded
+    | Source String -- Uppland etc.
+
+    | SymbolLine Symbol 
+    | TuneTitle String
+    -- User defined not supported
+
+    | Voice VoiceProps
+    | Words String -- TODO include separators
+    | ReferenceNumber Integer
+    | Transcription String
+    deriving (Eq, Ord, Show)
+
+type Key = (PitchClass, Mode)                   
+
+-- | Optional string, beats, frequency (3.1.8)
+type Tempo = (Maybe String, [Duration], Duration)
+
+type Symbol = ()
+
+data VoiceProps
+    = VoiceProps
+        (Maybe String)
+        (Maybe String)
+        (Maybe StemDirection)
+        (Maybe Clef)
+    deriving (Eq, Ord, Show)
+
+data Meter
+    = NoMeter
+    | Common
+    | Cut
+    | Simple Rational
+    | Compound [Integer] Integer
+    deriving (Eq, Ord, Show)
+
+data Mode
+    = Major
+    | Minor
+    | Ionian
+    | Dorian
+    | Phrygian
+    | Lydian
+    | Mixolydian
+    | Aeolian
+    | Locrian
+    deriving (Eq, Ord, Show)
+
+-- | Abc directive.
+type Directive = (String, String)
+    
+    
+
+readAbc :: String -> AbcFile
+readAbc = error "Not impl"
+
+showAbc :: AbcFile -> String
+showAbc = error "Not impl"
+
+infixr 5 :|:
+type a :|: b = Either a b
+
diff --git a/src/Music/Abc/Parser.hs b/src/Music/Abc/Parser.hs
new file mode 100644
--- /dev/null
+++ b/src/Music/Abc/Parser.hs
@@ -0,0 +1,141 @@
+
+-------------------------------------------------------------------------------------
+-- |
+-- Copyright   : (c) Hans Hoglund 2012
+--
+-- License     : BSD-style
+--
+-- Maintainer  : hans@hanshoglund.se
+-- Stability   : experimental
+-- Portability : portable
+--
+-------------------------------------------------------------------------------------
+
+module Music.Abc.Parser (
+    parse
+  ) where
+
+import Data.Monoid   
+import Data.Either
+import Control.Monad
+import Control.Applicative hiding ((<|>), optional, many)
+
+import Text.Parsec hiding (parse)
+import Text.Parsec.Token
+import Text.Parsec.String
+
+import Music.Abc
+
+-- TODO information field verification (header/body)
+
+-- ## Limitations:
+--
+--  * Limited support for *volatile* features
+--  * Limited support for text strings (§8.2)
+--    * No mnemonics
+--    * No entities
+--    * Unicode escapes are supported
+--  * No support for macros (§9)
+--  * No support for outdated syntax (§10)
+--  * Stylesheet directives are ignored (§11)
+--  * Typeset text is ignored (§2.2.3)
+--  * Strict interpretation assumed (§12)
+
+
+-- |
+-- Parse a module description, returning an error if unsuccessful.
+--
+parse :: String -> Either ParseError AbcFile
+parse = runParser abcFile () ""
+                 
+-------------------------------------------------------------------------------------
+-- Parsers
+-------------------------------------------------------------------------------------
+
+abcFile :: Parser AbcFile
+abcFile = do                      
+    -- optional byteOrderMark
+    string "%abc"
+    optional $ string "-" >> version
+    optional $ fileHeader    
+    fileBody
+    return undefined
+
+fileHeader :: Parser FileHeader
+fileHeader = fmap (uncurry FileHeader . partitionEithers) $ many1 $ mzero 
+    <|> fmap Left informationField 
+    <|> fmap Right styleSheetDirective
+
+fileBody :: Parser [Element]
+fileBody = (flip sepBy) emptyLine $ mzero
+    <|> fmap Tune abcTune
+    <|> fmap FreeText freeText 
+    <|> fmap TypesetText typeSetText
+
+informationField :: Parser Information
+informationField = do
+    letter
+    char ':'
+    -- TODO anything not \n
+    char '\n'              
+    return undefined
+
+-- Not parsed, see Limitations
+styleSheetDirective :: Parser Directive
+styleSheetDirective = mzero
+
+byteOrderMark :: Parser ()
+byteOrderMark = do
+    char '\xFFFE' <|> char '\xFEFF'
+    return ()
+
+version :: Parser Double
+version = undefined
+
+abcTune :: Parser AbcTune
+abcTune = undefined
+
+freeText :: Parser String
+freeText = undefined
+
+-- Not parsed, see Limitations
+typeSetText :: Parser String
+typeSetText = mzero
+
+
+-------------------------------------------------------------------------------------
+-- Lexer
+-------------------------------------------------------------------------------------
+
+lexer :: TokenParser ()
+lexer = makeTokenParser $ LanguageDef {
+    commentStart    =  "[r:",
+    commentEnd      =  "]",
+    commentLine     =  "%",
+    nestedComments  =  False,
+    identStart      =  (letter <|> char '_'),
+    identLetter     =  (alphaNum <|> char '_'),
+    opStart         =  mzero,
+    opLetter        =  mzero,
+    reservedNames   =  reservedNames,
+    reservedOpNames =  mzero,
+    caseSensitive   =  True
+    }
+    where
+        reservedNames = []
+
+-- Convenient synonyms, not exported
+llex   = lexeme lexer
+lnat   = natural lexer
+lstr   = stringLiteral lexer
+lname  = identifier lexer
+lres   = reserved lexer
+lspace = whiteSpace lexer
+
+emptyLine = newLine >> newLine
+newLine = string "\r\n" <|> string "\n"
+
+single x = [x]
+
+notSupported x = error $ "Not supported yet: " ++ x
+                                                         
