packages feed

srcloc 0.2.1 → 0.3.0

raw patch · 3 files changed

+46/−49 lines, 3 files

Files

Data/Loc.hs view
@@ -1,38 +1,9 @@--- Copyright (c) 2006-2012---         The President and Fellows of Harvard College.------ Redistribution and use in source and binary forms, with or without--- modification, are permitted provided that the following conditions--- are met:--- 1. Redistributions of source code must retain the above copyright---    notice, this list of conditions and the following disclaimer.--- 2. 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.--- 3. Neither the name of the University 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 UNIVERSITY 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 THE UNIVERSITY OR CONTRIBUTORS 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.---------------------------------------------------------------------------------- -- | -- Module      :  Data.Loc--- Copyright   :  (c) Harvard University 2006-2012+-- Copyright   :  (c) Harvard University 2006-2011+--                (c) Geoffrey Mainland 2011-2012 -- License     :  BSD-style -- Maintainer  :  mainland@eecs.harvard.edu------------------------------------------------------------------------------------  {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}@@ -51,7 +22,6 @@     locStart,     locEnd, -    mergeLoc,     (<-->),      SrcLoc(..),@@ -73,12 +43,14 @@ import Data.Generics (Data(..),Typeable(..)) #endif import Data.List (foldl')+import Data.Monoid (Monoid(..))  -- | Position type.-data Pos = Pos !String             -- ^ File-               {-# UNPACK #-} !Int -- ^ Line-               {-# UNPACK #-} !Int -- ^ Column-               {-# UNPACK #-} !Int -- ^ Character offset+data Pos = -- | Source file name, line, column, and character offset+           Pos !String+               {-# UNPACK #-} !Int+               {-# UNPACK #-} !Int+               {-# UNPACK #-} !Int #ifdef __GLASGOW_HASKELL__   deriving (Eq, Show, Data, Typeable) #else@@ -145,15 +117,16 @@ locEnd  NoLoc      = NoLoc locEnd  (Loc _ p)  = Loc p p --- | Calculate a 'Loc' with (minimal) span that includes both 'Loc' values.-mergeLoc :: Loc -> Loc -> Loc-mergeLoc  NoLoc        l            = l-mergeLoc  l            NoLoc        = l-mergeLoc  (Loc b1 e1)  (Loc b2 e2)  = Loc (min b1 b2) (max e1 e2)+instance Monoid Loc where+    mempty = NoLoc +    NoLoc     `mappend` l         = l+    l         `mappend` NoLoc     = l+    Loc b1 e1 `mappend` Loc b2 e2 = Loc (min b1 b2) (max e1 e2)+ -- | Merge the locations of two 'Located' values. (<-->) :: (Located a, Located b) => a -> b -> Loc-x <--> y = mergeLoc (locOf x) (locOf y)+x <--> y = locOf x `mappend` locOf y  infixl 6 <--> @@ -174,7 +147,7 @@  -- | A 'SrcLoc' with (minimal) span that includes two 'Located' values. srcspan :: (Located a, Located b) => a -> b -> SrcLoc-x `srcspan` y = SrcLoc (mergeLoc (locOf x) (locOf y))+x `srcspan` y = SrcLoc (locOf x `mappend` locOf y)  infixl 6 `srcspan` @@ -199,7 +172,7 @@     locOf :: a -> Loc      locOfList :: [a] -> Loc-    locOfList xs = foldl' mergeLoc NoLoc (map locOf xs)+    locOfList xs = mconcat (map locOf xs)  instance Located a => Located [a] where     locOf = locOfList
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2006-2010+Copyright (c) 2006-2011         The President and Fellows of Harvard College.  Redistribution and use in source and binary forms, with or without@@ -24,3 +24,26 @@ 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.++Copyright (c) 2011-2012, Geoffrey Mainland+All rights reserved.++Redistribution and use in source and binary forms, with or without modification,+are permitted provided that the following conditions are met:+1. Redistributions of source code must retain the above copyright notice, this+   list of conditions and the following disclaimer.++2. 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.++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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
srcloc.cabal view
@@ -1,9 +1,10 @@ name:           srcloc-version:        0.2.1+version:        0.3.0 cabal-version:  >= 1.6 license:        BSD3 license-file:   LICENSE-copyright:      (c) 2006-2012 Harvard University+copyright:      (c) 2006-2011 Harvard University+                (c) 2011-2012 Geoffrey Mainland author:         Geoffrey Mainland <mainland@eecs.harvard.edu> maintainer:     mainland@eecs.harvard.edu stability:      alpha@@ -19,8 +20,8 @@     Data.Loc    build-depends:-    base >= 4 && < 5,-    syb >= 0.1 && < 0.4+    base >= 4   && < 5,+    syb  >= 0.1 && < 0.4  source-repository head   type:     git