Replace type synonyms at List

That is, change the Elem, Lookup and Zip functions. This commit also
adds a sentence to README.mk.
This commit is contained in:
gspia 2020-01-06 12:09:16 +02:00
parent 4113cb1607
commit d29ab4b9af
2 changed files with 9 additions and 4 deletions

View File

@ -26,6 +26,8 @@ and passed to higher-order fcfs such as `Map`:
Eval (Map (FromMaybe 0) '[ 'Just 1, 'Nothing ]) = '[ 1, 0 ] :: [Nat]
```
Please, note that `FromMaybe 0` is partially applied type-level function.
Essential language extensions:
```haskell

View File

@ -164,14 +164,16 @@ type instance Eval (FindIndex p (a ': as)) =
(Pure ('Just 0))
(Map ((+) 1) =<< FindIndex p as))
type Elem a as = IsJust =<< FindIndex (TyEq a) as
data Elem :: a -> [a] -> Exp a
type instance Eval (Elem a as) = Eval (IsJust =<< FindIndex (TyEq a) as)
-- | Find an element associated with a key.
-- @
-- 'Lookup' :: k -> [(k, b)] -> 'Exp' ('Maybe' b)
-- @
type Lookup (a :: k) (as :: [(k, b)]) =
(Map Snd (Eval (Find (TyEq a <=< Fst) as)) :: Exp (Maybe b))
data Lookup :: k -> [(k, b)] -> Exp (Maybe b)
type instance Eval (Lookup (a :: k) (as :: [(k, b)])) =
Eval (Map Snd (Eval (Find (TyEq a <=< Fst) as)) :: Exp (Maybe b))
-- | Modify an element at a given index.
--
@ -194,7 +196,8 @@ type instance Eval (ZipWith f (a ': as) (b ': bs)) =
-- @
-- 'Zip' :: [a] -> [b] -> 'Exp' [(a, b)]
-- @
type Zip = ZipWith (Pure2 '(,))
data Zip :: [a] -> [b] -> Exp [(a, b)]
type instance Eval (Zip as bs) = Eval (ZipWith (Pure2 '(,)) as bs)
data Unzip :: Exp [(a, b)] -> Exp ([a], [b])
type instance Eval (Unzip as) = Eval (Foldr Cons2 '( '[], '[]) (Eval as))