module UVMHS.Core.Data.LazyList where import UVMHS.Core.Init import UVMHS.Core.Classes instance Null [a] where null :: [a] null = [a] forall a. [a] emptyLL instance Append [a] where ⧺ :: [a] -> [a] -> [a] (⧺) = [a] -> [a] -> [a] forall a. [a] -> [a] -> [a] appendLL instance Monoid [a] instance Functor [] where map :: forall a b. (a -> b) -> [a] -> [b] map = (a -> b) -> [a] -> [b] forall a b. (a -> b) -> [a] -> [b] mapLL instance Return [] where return :: forall a. a -> [a] return = a -> [a] forall a. a -> [a] singleLL instance Bind [] where ≫= :: forall a b. [a] -> (a -> [b]) -> [b] (≫=) = [a] -> (a -> [b]) -> [b] forall a b. [a] -> (a -> [b]) -> [b] bindLL instance Monad [] instance FunctorM [] where mapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapM = (a -> m b) -> [a] -> m [b] forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapMLL instance Single a [a] where single :: a -> [a] single = a -> [a] forall a. a -> [a] singleLL instance ToIter a [a] where iter :: [a] -> 𝐼 a iter = [a] -> 𝐼 a forall a. [a] -> 𝐼 a iterLL emptyLL ∷ [a] emptyLL :: forall a. [a] emptyLL = [] singleLL ∷ a → [a] singleLL :: forall a. a -> [a] singleLL a x = a x a -> [a] -> [a] forall a. a -> [a] -> [a] : [] consLL ∷ a → [a] → [a] consLL :: forall a. a -> [a] -> [a] consLL = (:) snocLL ∷ [a] → a → [a] snocLL :: forall a. [a] -> a -> [a] snocLL [a] xs a x = case [a] xs of [] → a x a -> [a] -> [a] forall a. a -> [a] -> [a] : [] a x' : [a] xs' → a x' a -> [a] -> [a] forall a. a -> [a] -> [a] : [a] -> a -> [a] forall a. [a] -> a -> [a] snocLL [a] xs' a x appendLL ∷ [a] → [a] → [a] appendLL :: forall a. [a] -> [a] -> [a] appendLL [a] xs [a] ys = case [a] xs of [] → [a] ys a x : [a] xs' → a x a -> [a] -> [a] forall a. a -> [a] -> [a] : [a] -> [a] -> [a] forall a. [a] -> [a] -> [a] appendLL [a] xs' [a] ys mapLL ∷ (a → b) → [a] → [b] mapLL :: forall a b. (a -> b) -> [a] -> [b] mapLL a -> b f [a] xs = case [a] xs of [] → [] a x : [a] xs' → a -> b f a x b -> [b] -> [b] forall a. a -> [a] -> [a] : (a -> b) -> [a] -> [b] forall a b. (a -> b) -> [a] -> [b] forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b map a -> b f [a] xs' bindLL ∷ [a] → (a → [b]) → [b] bindLL :: forall a b. [a] -> (a -> [b]) -> [b] bindLL [a] xs a -> [b] k = case [a] xs of [] → [] a x : [a] xs' → [b] -> [b] -> [b] forall a. [a] -> [a] -> [a] appendLL (a -> [b] k a x) ([a] -> (a -> [b]) -> [b] forall a b. [a] -> (a -> [b]) -> [b] bindLL [a] xs' a -> [b] k) mapMLL ∷ (Monad m) ⇒ (a → m b) → [a] → m [b] mapMLL :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapMLL a -> m b f [a] xs = case [a] xs of [] → [b] -> m [b] forall a. a -> m a forall (m :: * -> *) a. Return m => a -> m a return [] a x : [a] xs' → do b y ← a -> m b f a x [b] ys ← (a -> m b) -> [a] -> m [b] forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapMLL a -> m b f [a] xs' [b] -> m [b] forall a. a -> m a forall (m :: * -> *) a. Return m => a -> m a return ([b] -> m [b]) -> [b] -> m [b] forall a b. (a -> b) -> a -> b $ b y b -> [b] -> [b] forall a. a -> [a] -> [a] : [b] ys