From adeeb47e06cba3ac76b585b068324fac0446bad0 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Sun, 9 Feb 2014 20:45:11 +0000 Subject: cleanup the code for the FFI binding. The API is now more uniform with the Python and the Java bindings. Fixed a lot of memory leaks. --- src/runtime/haskell-bind/CId.hs | 56 ----------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/runtime/haskell-bind/CId.hs (limited to 'src/runtime/haskell-bind/CId.hs') diff --git a/src/runtime/haskell-bind/CId.hs b/src/runtime/haskell-bind/CId.hs deleted file mode 100644 index 74db63c2c..000000000 --- a/src/runtime/haskell-bind/CId.hs +++ /dev/null @@ -1,56 +0,0 @@ -module CId (CId(..), - mkCId, wildCId, - readCId, showCId, - - -- utils - pCId, pIdent, ppCId) where - -import Control.Monad -import qualified Data.ByteString.Char8 as BS -import Data.Char -import qualified Text.ParserCombinators.ReadP as RP -import qualified Text.PrettyPrint as PP - - - --- | An abstract data type that represents --- identifiers for functions and categories in PGF. -newtype CId = CId BS.ByteString deriving (Eq,Ord) - -wildCId :: CId -wildCId = CId (BS.singleton '_') - --- | Creates a new identifier from 'String' -mkCId :: String -> CId -mkCId s = CId (BS.pack s) - --- | Reads an identifier from 'String'. The function returns 'Nothing' if the string is not valid identifier. -readCId :: String -> Maybe CId -readCId s = case [x | (x,cs) <- RP.readP_to_S pCId s, all isSpace cs] of - [x] -> Just x - _ -> Nothing - --- | Renders the identifier as 'String' -showCId :: CId -> String -showCId (CId x) = BS.unpack x - -instance Show CId where - showsPrec _ = showString . showCId - -instance Read CId where - readsPrec _ = RP.readP_to_S pCId - -pCId :: RP.ReadP CId -pCId = do s <- pIdent - if s == "_" - then RP.pfail - else return (mkCId s) - -pIdent :: RP.ReadP String -pIdent = liftM2 (:) (RP.satisfy isIdentFirst) (RP.munch isIdentRest) - where - isIdentFirst c = c == '_' || isLetter c - isIdentRest c = c == '_' || c == '\'' || isAlphaNum c - -ppCId :: CId -> PP.Doc -ppCId = PP.text . showCId -- cgit v1.2.3