Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# Language
- Rank2Types,
- PolyKinds,
- TypeFamilies,
- DatatypeContexts,
- MultiParamTypeClasses,
- UndecidableInstances,
- UndecidableSuperClasses
- #-}
- import GHC.Exts
- {-
- type family State (x :: * -> * -> *) :: Constraint where
- State Basecase = ()
- State (Nested xs) = ()
- data Basecase s a where
- Stream' :: Stream s a -> Basecase s a
- Linear' :: Linear s a -> Basecase s a
- Stack' :: Stack s a -> Basecase s a
- this was the original definition of "Base"
- however, having converted it to a type family emulating a "closed class" below
- it can no longer be matched over as in the type family State above.
- how can this process work in a way that retains this ability?
- we cannot match over constraints...
- -}
- data Stream s a = Stream (a,s)
- data Linear s a = Linear (a,s) | End a
- data Stack s a = Stack (a,s) | Empty
- type family Base (b :: * -> * -> *) :: Constraint where
- Base Stream = ()
- Base Linear = ()
- Base Stack = ()
- class Base (FlatBase f) => Flat f where -- not considering Nested Base functors yet, so no Trees etc
- type FlatBase f :: * -> * -> *
- type State b s a = Base b => s -> b s a
- type CoState b s a = Base b => b s a -> s
- class Flat f => Get f where
- get :: CoState (FlatBase f) (f a) a
- class Flat f => Set f where
- set :: State (FlatBase f) (f a) a
- data (Get f,Set f) => Zipper f a = Zipper [a] (f a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement