Move code to new FillSig module

- Clean up a lot of code
This commit is contained in:
Alejandro Serrano
2014-06-27 18:38:15 +02:00
parent 3ef1979f67
commit 2ab6991d95
7 changed files with 234 additions and 195 deletions

View File

@@ -1,6 +1,6 @@
{-# LANGUAGE FlexibleInstances, FlexibleContexts, OverlappingInstances #-}
module Language.Haskell.GhcMod.Convert (convert, convert') where
module Language.Haskell.GhcMod.Convert (convert, convert', emptyResult, whenFound) where
import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.Types
@@ -115,3 +115,11 @@ quote opt str = ("\"" ++) . (quote' str ++) . ("\"" ++)
| otherwise = x : quote' xs
----------------------------------------------------------------
-- Empty result to be returned when no info can be gathered
emptyResult :: Monad m => Options -> m String
emptyResult opt = return $ convert opt ([] :: [String])
-- Return an emptyResult when Nothing
whenFound :: (Monad m, ToString b) => Options -> m (Maybe a) -> (a -> b) -> m String
whenFound opt from f = maybe (emptyResult opt) (return . convert opt . f) =<< from