Implement IsString for (Located HaskLikeAtom)
ckoparkar
8 years ago
| 26 | 26 |
, commonLispNumberAnyBase
|
| 27 | 27 |
, gnuM4NumberAnyBase
|
| 28 | 28 |
-- ** Source locations
|
| 29 | |
, Location(..), Located(..), located
|
| 29 |
, Location(..), Located(..), located, dLocation
|
| 30 | 30 |
) where
|
| 31 | 31 |
|
| 32 | 32 |
#if !MIN_VERSION_base(4,8,0)
|
|
| 37 | 37 |
import Data.Text (Text)
|
| 38 | 38 |
import qualified Data.Text as T
|
| 39 | 39 |
import Text.Parsec
|
| 40 |
import Text.Parsec.Pos (newPos)
|
| 40 | 41 |
import Text.Parsec.Text (Parser)
|
| 41 | 42 |
|
| 42 | 43 |
-- | Parse an identifier according to the R5RS Scheme standard. This
|
|
| 353 | 354 |
end <- getPosition
|
| 354 | 355 |
return $ At (Span begin end) result
|
| 355 | 356 |
|
| 357 |
-- | A default location value
|
| 358 |
dLocation :: Location
|
| 359 |
dLocation = Span dPos dPos
|
| 360 |
where dPos = newPos "" 0 0
|
| 356 | 361 |
|
| 357 | 362 |
{- $intro
|
| 358 | 363 |
|
| 1 |
{-# LANGUAGE FlexibleInstances #-}
|
| 1 | 2 |
{-# LANGUAGE OverloadedStrings #-}
|
| 2 | 3 |
|
| 3 | 4 |
module Data.SCargot.Language.HaskLike
|
|
| 56 | 57 |
|
| 57 | 58 |
instance IsString HaskLikeAtom where
|
| 58 | 59 |
fromString = HSIdent . fromString
|
| 60 |
|
| 61 |
instance IsString (Located HaskLikeAtom) where
|
| 62 |
fromString = (At dLocation) . HSIdent . fromString
|
| 59 | 63 |
|
| 60 | 64 |
-- | Parse a Haskell string literal as defined by the Haskell 2010
|
| 61 | 65 |
-- language specification.
|