Skip to content

Commit

Permalink
Remove unused 'Value' constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
evincarofautumn committed Aug 5, 2017
1 parent ce650fa commit 1650f1c
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 43 deletions.
6 changes: 0 additions & 6 deletions lib/Kitten/Amd64.hs
Expand Up @@ -680,19 +680,13 @@ term t = case t of

value :: Origin -> Term.Value Type -> CodeGen ()
value origin v = case v of
Term.Algebraic{} -> error
"algebraic data type appeared during code generation"
Term.Array{} -> error
"array appeared during code generation"
Term.Capture{} -> error
"capture appeared during code generation"
Term.Character c -> do
comment ["push char ", Text.pack $ show c]
indented $ pushSmall $ fromIntegral $ fromEnum c
Term.Closed (ClosureIndex index) -> do
comment ["closure.", Text.pack $ show index]
Term.Closure{} -> error
"closure appeared during code generation"
Term.Float f -> do
comment ["push float ", Text.pack $ show (Literal.floatValue f :: Double)]
-- TODO: Use FPU stack.
Expand Down
3 changes: 0 additions & 3 deletions lib/Kitten/Desugar/Infix.hs
Expand Up @@ -118,12 +118,9 @@ desugar dictionary definition = do

desugarValue :: Value () -> K (Value ())
desugarValue value = case value of
Algebraic{} -> error "adt should not appear before runtime"
Array{} -> error "array should not appear before runtime"
Capture names body -> Capture names <$> desugarTerms' body
Character{} -> return value
Closed{} -> error "closed name should not appear before infix desugaring"
Closure{} -> error "closure should not appear before runtime"
Float{} -> return value
Integer{} -> return value
Local{} -> error "local name should not appear before infix desugaring"
Expand Down
3 changes: 0 additions & 3 deletions lib/Kitten/Infer.hs
Expand Up @@ -431,8 +431,6 @@ inferValue
-> Value a
-> K (Value Type, Type, TypeEnv)
inferValue dictionary tenvFinal tenv0 origin value = case value of
Algebraic{} -> error "adt should not appear before runtime"
Array{} -> error "array should not appear before runtime"
Capture names term -> do
let types = map (TypeEnv.getClosed tenv0) names
let oldClosure = TypeEnv.closure tenv0
Expand All @@ -443,7 +441,6 @@ inferValue dictionary tenvFinal tenv0 origin value = case value of
Character x -> return (Character x, TypeConstructor origin "Char", tenv0)
Closed (ClosureIndex index) -> return
(Closed $ ClosureIndex index, TypeEnv.closure tenv0 !! index, tenv0)
Closure{} -> error "closure should not appear before runtime"
Float x -> let
ctor = case Literal.floatBits x of
Float32 -> "Float32"
Expand Down
3 changes: 0 additions & 3 deletions lib/Kitten/Interpret.hs
Expand Up @@ -88,10 +88,7 @@ data Rep

valueRep :: (Show a) => Value a -> Rep
valueRep value = case value of
Term.Algebraic index fields -> Algebraic index (valueRep <$> fields)
Term.Array values -> Array (valueRep <$> values)
Term.Character c -> Character c
Term.Closure name closure -> Closure name (valueRep <$> closure)
Term.Float literal -> case Literal.floatBits literal of
Bits.Float32 -> Float32 $ Literal.floatValue literal
Bits.Float64 -> Float64 $ Literal.floatValue literal
Expand Down
3 changes: 0 additions & 3 deletions lib/Kitten/Resolve.hs
Expand Up @@ -100,12 +100,9 @@ term dictionary vocabulary = recur

value :: Dictionary -> Qualifier -> Value () -> Resolved (Value ())
value dictionary vocabulary v = case v of
Algebraic{} -> error "adt should not appear before runtime"
Array{} -> error "array should not appear before runtime"
Capture{} -> error "closure should not appear before name resolution"
Character{} -> return v
Closed{} -> error "closed name should not appear before name resolution"
Closure{} -> error "closure should not appear before runtime"
Float{} -> return v
Integer{} -> return v
Local{} -> error "local name should not appear before name resolution"
Expand Down
6 changes: 0 additions & 6 deletions lib/Kitten/Scope.hs
Expand Up @@ -59,12 +59,9 @@ scope = scopeTerm [0]

scopeValue :: [Int] -> Value () -> Value ()
scopeValue stack value = case value of
Algebraic{} -> value
Array{} -> error "array should not appear before runtime"
Capture{} -> error "capture should not appear before scope resolution"
Character{} -> value
Closed{} -> error "closed name should not appear before scope resolution"
Closure{} -> error "closure should not appear before runtime"
Float{} -> value
Integer{} -> value
Local{} -> value
Expand Down Expand Up @@ -132,8 +129,6 @@ captureTerm term = case term of

captureValue :: Value () -> Captured (Value ())
captureValue value = case value of
Algebraic{} -> error "adt should not appear before runtime"
Array{} -> error "array should not appear before runtime"
Capture names term -> Capture <$> mapM close names <*> pure term
where

Expand All @@ -147,7 +142,6 @@ captureValue value = case value of
ClosedClosure{} -> return original
Character{} -> return value
Closed{} -> return value
Closure{} -> error "closure should not appear before runtime"
Float{} -> return value
Integer{} -> return value
Local index -> do
Expand Down
17 changes: 1 addition & 16 deletions lib/Kitten/Term.hs
Expand Up @@ -36,7 +36,6 @@ module Kitten.Term

import Data.List (intersperse, partition)
import Data.Text (Text)
import Data.Vector (Vector)
import Kitten.Entry.Parameter (Parameter(..))
import Kitten.Literal (IntegerLiteral, FloatLiteral)
import Kitten.Name
Expand All @@ -46,7 +45,6 @@ import Kitten.Signature (Signature)
import Kitten.Type (Type, TypeId)
import Text.PrettyPrint.HughesPJClass (Pretty(..))
import qualified Data.Text as Text
import qualified Data.Vector as Vector
import qualified Kitten.Kind as Kind
import qualified Kitten.Pretty as Pretty
import qualified Kitten.Signature as Signature
Expand Down Expand Up @@ -129,18 +127,12 @@ data Permit = Permit
-- values in the interpreter.

data Value a
-- | An ADT instance.
= Algebraic !ConstructorIndex [Value a]
-- | An array of values.
| Array !(Vector (Value a))
-- | A quotation with explicit variable capture; see "Kitten.Scope".
| Capture [Closed] !(Term a)
= Capture [Closed] !(Term a)
-- | A character literal.
| Character !Char
-- | A captured variable.
| Closed !ClosureIndex
-- | A closure value.
| Closure !Qualified [Value a]
-- | A floating-point literal.
| Float !FloatLiteral
-- | An integer literal.
Expand Down Expand Up @@ -259,12 +251,9 @@ stripMetadata term = case term of

stripValue :: Value a -> Value ()
stripValue v = case v of
Algebraic a b -> Algebraic a (map stripValue b)
Array a -> Array (fmap stripValue a)
Capture a b -> Capture a (stripMetadata b)
Character a -> Character a
Closed a -> Closed a
Closure a b -> Closure a (map stripValue b)
Float a -> Float a
Integer a -> Integer a
Local a -> Local a
Expand Down Expand Up @@ -313,17 +302,13 @@ instance Pretty Permit where

instance Pretty (Value a) where
pPrint value = case value of
Algebraic{} -> "<adt>"
Array values -> Pretty.brackets $ Pretty.list
$ Vector.toList $ fmap pPrint values
Capture names term -> Pretty.hcat
[ Pretty.char '$'
, Pretty.parens $ Pretty.list $ map pPrint names
, Pretty.braces $ pPrint term
]
Character c -> Pretty.quotes $ Pretty.char c
Closed (ClosureIndex index) -> "closure." Pretty.<> Pretty.int index
Closure{} -> "<closure>"
Float f -> pPrint f
Integer i -> pPrint i
Local (LocalIndex index) -> "local." Pretty.<> Pretty.int index
Expand Down
3 changes: 0 additions & 3 deletions lib/Kitten/Zonk.hs
Expand Up @@ -83,12 +83,9 @@ value :: TypeEnv -> Value Type -> Value Type
value tenv0 = go
where
go v = case v of
Algebraic{} -> error "adt should not appear before runtime"
Array{} -> error "array should not appear before runtime"
Capture names body -> Capture names $ term tenv0 body
Character{} -> v
Closed{} -> v
Closure{} -> v
Float{} -> v
Integer{} -> v
Local{} -> v
Expand Down

0 comments on commit 1650f1c

Please sign in to comment.