gdritter repos s-cargot / c01b118
Implement IsString for (Located HaskLikeAtom) ckoparkar 6 years ago
2 changed file(s) with 10 addition(s) and 1 deletion(s). Collapse all Expand all
2626 , commonLispNumberAnyBase
2727 , gnuM4NumberAnyBase
2828 -- ** Source locations
29 , Location(..), Located(..), located
29 , Location(..), Located(..), located, dLocation
3030 ) where
3131
3232 #if !MIN_VERSION_base(4,8,0)
3737 import Data.Text (Text)
3838 import qualified Data.Text as T
3939 import Text.Parsec
40 import Text.Parsec.Pos (newPos)
4041 import Text.Parsec.Text (Parser)
4142
4243 -- | Parse an identifier according to the R5RS Scheme standard. This
353354 end <- getPosition
354355 return $ At (Span begin end) result
355356
357 -- | A default location value
358 dLocation :: Location
359 dLocation = Span dPos dPos
360 where dPos = newPos "" 0 0
356361
357362 {- $intro
358363
1 {-# LANGUAGE FlexibleInstances #-}
12 {-# LANGUAGE OverloadedStrings #-}
23
34 module Data.SCargot.Language.HaskLike
5657
5758 instance IsString HaskLikeAtom where
5859 fromString = HSIdent . fromString
60
61 instance IsString (Located HaskLikeAtom) where
62 fromString = (At dLocation) . HSIdent . fromString
5963
6064 -- | Parse a Haskell string literal as defined by the Haskell 2010
6165 -- language specification.