module Fresnel.List
( -- * Optics
  uncons_
, head_
, tail_
) where

import qualified Data.List as List
import           Fresnel.Optional
import           Fresnel.Prism
import           Fresnel.Tuple

-- Optics

uncons_ :: Prism' [a] (a, [a])
uncons_ :: forall a (p :: * -> * -> *).
IsPrism p =>
Optic p [a] [a] (a, [a]) (a, [a])
uncons_ = ((a, [a]) -> [a])
-> ([a] -> Maybe (a, [a])) -> Prism [a] [a] (a, [a]) (a, [a])
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((a -> [a] -> [a]) -> (a, [a]) -> [a]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (:)) [a] -> Maybe (a, [a])
forall a. [a] -> Maybe (a, [a])
List.uncons

head_ :: Optional' [a] a
head_ :: forall a (p :: * -> * -> *). IsOptional p => Optic p [a] [a] a a
head_ = Optic p [a] [a] (a, [a]) (a, [a])
forall a (p :: * -> * -> *).
IsPrism p =>
Optic p [a] [a] (a, [a]) (a, [a])
uncons_Optic p [a] [a] (a, [a]) (a, [a])
-> (p a a -> p (a, [a]) (a, [a])) -> p a a -> p [a] [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.p a a -> p (a, [a]) (a, [a])
forall a b a' (p :: * -> * -> *).
IsLens p =>
Optic p (a, b) (a', b) a a'
fst_

tail_ :: Optional' [a] [a]
tail_ :: forall a (p :: * -> * -> *).
IsOptional p =>
Optic p [a] [a] [a] [a]
tail_ = Optic p [a] [a] (a, [a]) (a, [a])
forall a (p :: * -> * -> *).
IsPrism p =>
Optic p [a] [a] (a, [a]) (a, [a])
uncons_Optic p [a] [a] (a, [a]) (a, [a])
-> (p [a] [a] -> p (a, [a]) (a, [a])) -> p [a] [a] -> p [a] [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.p [a] [a] -> p (a, [a]) (a, [a])
forall a b b' (p :: * -> * -> *).
IsLens p =>
Optic p (a, b) (a, b') b b'
snd_