Remove List/concat

This can be implemented in terms of `List/build` and `List/fold`, and those
permit build/fold fusion, unlike `List/concat`
This commit is contained in:
Gabriel Gonzalez 2016-10-14 21:13:38 -07:00
parent 6f35500d8e
commit e3b54792d1
3 changed files with 0 additions and 26 deletions

View File

@ -246,8 +246,6 @@ data Expr a
| ListIndexed
-- | > ListReverse ~ List/reverse
| ListReverse
-- | > ListConcat ~ List/concat
| ListConcat
-- | > Maybe ~ Maybe
| Maybe
-- | > MaybeLit t [e] ~ [e] : Maybe t
@ -321,7 +319,6 @@ instance Monad Expr where
ListLast >>= _ = ListLast
ListIndexed >>= _ = ListIndexed
ListReverse >>= _ = ListReverse
ListConcat >>= _ = ListConcat
Maybe >>= _ = Maybe
MaybeLit t es >>= k = MaybeLit (t >>= k) (fmap (>>= k) es)
MaybeFold >>= _ = MaybeFold
@ -515,8 +512,6 @@ buildExpr6 ListIndexed =
"List/indexed"
buildExpr6 ListReverse =
"List/reverse"
buildExpr6 ListConcat =
"List/concat"
buildExpr6 List =
"List"
buildExpr6 Maybe =
@ -1796,9 +1791,6 @@ typeWith _ ListIndexed = do
(App List (Record (Data.Map.fromList kts))) ) )
typeWith _ ListReverse = do
return (Pi "a" (Const Type) (Pi "_" (App List "a") (App List "a")))
typeWith _ ListConcat = do
return
(Pi "a" (Const Type) (Pi "_" (App List (App List "a")) (App List "a")))
typeWith _ Maybe = do
return (Pi "_" (Const Type) (Const Type))
typeWith ctx e@(MaybeLit t xs ) = do
@ -1957,17 +1949,6 @@ normalize e = case e of
]
App (App ListReverse _) (ListLit t xs) ->
normalize (ListLit t (Data.Vector.reverse xs))
App (App ListConcat _) (ListLit (App List t) xs)
| Data.Vector.all isList xs ->
case traverse extract xs of
Just ys -> normalize (ListLit t (Control.Monad.join ys))
_ -> error "normalize: Malformed `List/concat`"
where
isList (ListLit _ _) = True
isList _ = False
extract (ListLit _ y) = Just y
extract _ = Nothing
App (App (App (App (App MaybeFold _) (MaybeLit _ xs)) _) just) nothing ->
normalize (maybe nothing just' (toMaybe xs))
where

View File

@ -106,7 +106,6 @@ tokens :-
"List/last" { emit ListLast }
"List/indexed" { emit ListIndexed }
"List/reverse" { emit ListReverse }
"List/concat" { emit ListConcat }
"Maybe" { emit Maybe }
"Maybe/fold" { emit MaybeFold }
"absurd" { emit Absurd }
@ -274,7 +273,6 @@ data Token
| ListLast
| ListIndexed
| ListReverse
| ListConcat
| Maybe
| MaybeFold
| TextLit Builder
@ -391,8 +389,6 @@ instance Buildable Token where
= "List/indexed"
build ListReverse
= "List/reverse"
build ListConcat
= "List/concat"
build ListFold
= "List/fold"
build Maybe

View File

@ -91,7 +91,6 @@ import qualified NeatInterpolation
'List/last' { Dhall.Lexer.ListLast }
'List/indexed' { Dhall.Lexer.ListIndexed }
'List/reverse' { Dhall.Lexer.ListReverse }
'List/concat' { Dhall.Lexer.ListConcat }
'Maybe' { Dhall.Lexer.Maybe }
'Maybe/fold' { Dhall.Lexer.MaybeFold }
'absurd' { Dhall.Lexer.Absurd }
@ -218,8 +217,6 @@ Expr6
{ ListIndexed }
| 'List/reverse'
{ ListReverse }
| 'List/concat'
{ ListConcat }
| 'Maybe'
{ Maybe }
| 'Maybe/fold'