module CIDemo.Api.Reverse.Internal where

import           Prelude       hiding (reverse)
import           Rest
import qualified Rest.Resource as R

import           CIDemo.Types

resource :: Resource CIDemo CIDemo () Void Void
resource = mkResourceId
        { R.name   = "reverse"
        , R.schema = noListing $ named []
        , R.create = Just create
        }

create :: Handler CIDemo
create = mkInputHandler (stringO . someO . stringI . someI) $ \txt ->
        return $ reverse txt

reverse :: [a] -> [a]
reverse = foldl (flip (:)) []
