module System.Shana.Type where

import Control.Arrow
import Control.Category
import Prelude hiding ((.), id)
import Control.Monad ((>=>))

newtype Shana a b = Shana { runShana :: a -> IO [b] }


instance Category Shana where
  id = Shana $ return . return
  Shana g . Shana f = Shana $ f >=> mapM g >=> return . concat


instance Arrow Shana where
  arr f = Shana $ return . return . f

  first (Shana f) = Shana $ \(x, y) -> do
    xs <- f x
    return $ zip xs (repeat y)

