module Language.Haskell.Format.Internal
  ( mkFormatter
  , mkSuggester
  ) where

import Language.Haskell.Format.Types

mkFormatter :: (HaskellSource -> Either String HaskellSource) -> Formatter
mkFormatter :: (HaskellSource -> Either String HaskellSource) -> Formatter
mkFormatter HaskellSource -> Either String HaskellSource
f = (HaskellSource -> Either String Reformatted) -> Formatter
Formatter ((HaskellSource -> Reformatted)
-> Either String HaskellSource -> Either String Reformatted
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (HaskellSource -> [Suggestion] -> Reformatted
`Reformatted` []) (Either String HaskellSource -> Either String Reformatted)
-> (HaskellSource -> Either String HaskellSource)
-> HaskellSource
-> Either String Reformatted
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HaskellSource -> Either String HaskellSource
f)

mkSuggester :: (HaskellSource -> Either String [Suggestion]) -> Formatter
mkSuggester :: (HaskellSource -> Either String [Suggestion]) -> Formatter
mkSuggester HaskellSource -> Either String [Suggestion]
f = (HaskellSource -> Either String Reformatted) -> Formatter
Formatter ((HaskellSource -> Either String Reformatted) -> Formatter)
-> (HaskellSource -> Either String Reformatted) -> Formatter
forall a b. (a -> b) -> a -> b
$ \HaskellSource
source -> HaskellSource -> [Suggestion] -> Reformatted
Reformatted HaskellSource
source ([Suggestion] -> Reformatted)
-> Either String [Suggestion] -> Either String Reformatted
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellSource -> Either String [Suggestion]
f HaskellSource
source