module Data.Stream.Hinze.Idiom where

import Prelude (($))

-- | A reimplementation of  the classic 'idioms' class, which is now
-- known as Applicative.
--
class Idiom f where
   pure  ::  a -> f a
   (<>)  ::  f (a -> b) -> (f a -> f b)

   repeat  ::  a -> f a
   map     ::  (a -> b) -> (f a -> f b)
   zip     ::  (a -> b -> c) -> (f a -> f b -> f c)

   pure  =  repeat
   (<>)  =  zip ($)

   repeat a   =  pure a
   map f s    =  pure f <> s
   zip g s t  =  pure g <> s <> t