{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Data.Type.Lens.Example (
SetExample
, ViewExample
, ToExample
, OverExample
, TraversalExample
, NestedExample
, FoldExample
, UnsafeExample
, IxExample
, CloneExample
, SetExample'
, ViewExample'
, ToExample'
, OverExample'
, TraversalExample'
, NestedExample'
, FoldExample'
, IxExample'
, UnsafeExample'
, CloneExample'
) where
import Data.Singletons.Prelude
import Data.Singletons.Prelude.Function
import Data.Type.Lens
type SetExample = Set L1_ 'True '("hello", 6 )
type ViewExample = View L2_ '("hello", 6 )
type ToExample = View (To_ SndSym0) '("hello", 6 )
type OverExample = Over L2_ NotSym0 '("hello", 'True )
type TraversalExample = Over Traverse_ NotSym0 '[ 'True, 'False, 'False ]
type NestedExample = View (L2_ .@ L1_) '("hello", '(6, 'False ) )
type FoldExample = ToListOf (Traverse_ .@ L1_)
'[ '("hello", 'True )
, '("world", 'False)
, '("curry", 'False)
]
type UnsafeExample = UnsafePreview Traverse_ '[]
type IxExample = Set (IxList_ ('S 'Z)) "haskell"
'["hello", "world", "curry"]
type CloneExample l = View (CloneLens_ l) (Over (CloneLens_ l) NotSym0 '( 'True, 'False ))
type SetExample' = '("hello", 6 ) & L1_ .~ 'True
type ViewExample' = '("hello", 6 ) ^. L2_
type ToExample' = '("hello", 6 ) ^. To_ SndSym0
type OverExample' = '("hello", 'True ) & L2_ %~ NotSym0
type TraversalExample' = '[ 'True, 'False, 'False ] & Traverse_ %~ NotSym0
type NestedExample' = '("hello", '(6, 'False ) ) ^. L2_ .@ L1_
type FoldExample' = '[ '("hello", 'True )
, '("world", 'False)
, '("curry", 'False)
] ^.. Traverse_ .@ L1_
type UnsafeExample' = '[] ^?! Traverse_
type IxExample' = '["hello","world","curry"] & IxList_ ('S 'Z) .~ "haskell"
type CloneExample' l = ('( 'True, 'False ) & CloneLens_ l %~ NotSym0) ^. CloneLens_ l