Skip to content
1 change: 0 additions & 1 deletion builder/src/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ fork work =
_ <- forkIO $ putMVar mvar =<< work
return mvar

{-# INLINE forkWithKey #-}
forkWithKey :: (k -> a -> IO b) -> Map.Map k a -> IO (Map.Map k (MVar b))
forkWithKey func dict =
Map.traverseWithKey (\k v -> fork (func k v)) dict
Expand Down
10 changes: 0 additions & 10 deletions builder/src/Deps/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,6 @@ diffType oldType newType =
diffFields fields fields'
(Just oldExt, Just newExt) ->
(:) (oldExt, newExt) <$> diffFields fields fields'
(Type.Unit, Type.Unit) ->
Just []
(Type.Tuple a b cs, Type.Tuple x y zs) ->
if length cs /= length zs
then Nothing
else do
aVars <- diffType a x
bVars <- diffType b y
cVars <- concat <$> zipWithM diffType cs zs
return (aVars ++ bVars ++ cVars)
(_, _) ->
Nothing

Expand Down
6 changes: 0 additions & 6 deletions builder/src/Reporting/Task.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ mapError func (Task task) =

-- IO

{-# INLINE io #-}
io :: IO a -> Task x a
io work =
Task $ \ok _ -> work >>= ok
Expand All @@ -60,18 +59,15 @@ eio func work =
-- INSTANCES

instance Functor (Task x) where
{-# INLINE fmap #-}
fmap func (Task taskA) =
Task $ \ok err ->
let okA arg = ok (func arg)
in taskA okA err

instance Applicative (Task x) where
{-# INLINE pure #-}
pure a =
Task $ \ok _ -> ok a

{-# INLINE (<*>) #-}
(<*>) (Task taskFunc) (Task taskArg) =
Task $ \ok err ->
let okFunc func =
Expand All @@ -80,10 +76,8 @@ instance Applicative (Task x) where
in taskFunc okFunc err

instance Monad (Task x) where
{-# INLINE return #-}
return = pure

{-# INLINE (>>=) #-}
(>>=) (Task taskA) callback =
Task $ \ok err ->
let okA a =
Expand Down
2 changes: 0 additions & 2 deletions cabal.config

This file was deleted.

22 changes: 6 additions & 16 deletions compiler/src/AST/Canonical.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ data Expr_
| Access Expr (A.Located Name)
| Update Name Expr (Map.Map Name FieldUpdate)
| Record (Map.Map Name Expr)
| Unit
| Tuple Expr Expr (Maybe Expr)

data CaseBranch
= CaseBranch Pattern Expr
Expand Down Expand Up @@ -132,8 +130,6 @@ data Pattern_
| PVar Name
| PRecord [PatternRecordField]
| PAlias Pattern Name
| PUnit
| PTuple Pattern Pattern (Maybe Pattern)
| PArray [Pattern]
| PBool Union Bool
| PChr ES.String
Expand Down Expand Up @@ -175,8 +171,6 @@ data Type
| TVar Name
| TType ModuleName.Canonical Name [Type]
| TRecord (Map.Map Name FieldType) (Maybe Name)
| TUnit
| TTuple Type Type (Maybe Type)
| TAlias ModuleName.Canonical Name [(Name, Type)] AliasType
deriving (Eq)

Expand Down Expand Up @@ -307,18 +301,16 @@ instance Binary Type where
TLambda a b -> putWord8 0 >> put a >> put b
TVar a -> putWord8 1 >> put a
TRecord a b -> putWord8 2 >> put a >> put b
TUnit -> putWord8 3
TTuple a b c -> putWord8 4 >> put a >> put b >> put c
TAlias a b c d -> putWord8 5 >> put a >> put b >> put c >> put d
TAlias a b c d -> putWord8 3 >> put a >> put b >> put c >> put d
TType home name ts ->
let potentialWord = length ts + 7
let potentialWord = length ts + 5
in if potentialWord <= fromIntegral (maxBound :: Word8)
then do
putWord8 (fromIntegral potentialWord)
put home
put name
mapM_ put ts
else putWord8 6 >> put home >> put name >> put ts
else putWord8 4 >> put home >> put name >> put ts

get =
do
Expand All @@ -327,11 +319,9 @@ instance Binary Type where
0 -> liftM2 TLambda get get
1 -> liftM TVar get
2 -> liftM2 TRecord get get
3 -> return TUnit
4 -> liftM3 TTuple get get get
5 -> liftM4 TAlias get get get get
6 -> liftM3 TType get get get
n -> liftM3 TType get get (replicateM (fromIntegral (n - 7)) get)
3 -> liftM4 TAlias get get get get
4 -> liftM3 TType get get get
n -> liftM3 TType get get (replicateM (fromIntegral (n - 5)) get)

instance Binary AliasType where
put aliasType =
Expand Down
7 changes: 0 additions & 7 deletions compiler/src/AST/Optimized.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ data Expr
| Access Expr Name
| Update Expr (Map.Map Name Expr)
| Record (Map.Map Name Expr)
| Unit
| Tuple Expr Expr (Maybe Expr)

data Global = Global ModuleName.Canonical Name

Expand Down Expand Up @@ -142,7 +140,6 @@ data EffectsType = Cmd | Sub | Fx

-- GRAPHS

{-# NOINLINE empty #-}
empty :: GlobalGraph
empty =
GlobalGraph Map.empty Map.empty
Expand Down Expand Up @@ -232,8 +229,6 @@ instance Binary Expr where
Access a b -> putWord8 21 >> put a >> put b
Update a b -> putWord8 22 >> put a >> put b
Record a -> putWord8 23 >> put a
Unit -> putWord8 24
Tuple a b c -> putWord8 25 >> put a >> put b >> put c

get =
do
Expand Down Expand Up @@ -263,8 +258,6 @@ instance Binary Expr where
21 -> liftM2 Access get get
22 -> liftM2 Update get get
23 -> liftM Record get
24 -> pure Unit
25 -> liftM3 Tuple get get get
_ -> fail "problem getting Opt.Expr binary"

instance Binary Def where
Expand Down
6 changes: 0 additions & 6 deletions compiler/src/AST/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ data Expr_
| Access Expr (A.Located Name)
| Update (A.Located Name) [(A.Located Name, Expr)]
| Record [(A.Located Name, Expr)]
| Unit
| Tuple Expr Expr [Expr]

data VarType = LowVar | CapVar

Expand All @@ -82,8 +80,6 @@ data Pattern_
| PVar Name
| PRecord [RecordFieldPattern]
| PAlias Pattern (A.Located Name)
| PUnit
| PTuple Pattern Pattern [Pattern]
| PCtor A.Region Name [Pattern]
| PCtorQual A.Region Name Name [Pattern]
| PArray [Pattern]
Expand All @@ -106,8 +102,6 @@ data Type_
| TType A.Region Name [Type]
| TTypeQual A.Region Name Name [Type]
| TRecord [(A.Located Name, Type)] (Maybe (A.Located Name))
| TUnit
| TTuple Type Type [Type]

-- MODULE

Expand Down
11 changes: 0 additions & 11 deletions compiler/src/AST/Utils/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ dealiasHelp typeTable tipe =
TAlias home name (map (fmap (dealiasHelp typeTable)) args) t'
TType home name args ->
TType home name (map (dealiasHelp typeTable) args)
TUnit ->
TUnit
TTuple a b maybeC ->
TTuple
(dealiasHelp typeTable a)
(dealiasHelp typeTable b)
(fmap (dealiasHelp typeTable) maybeC)

dealiasField :: Map.Map Name.Name Type -> FieldType -> FieldType
dealiasField typeTable (FieldType index tipe) =
Expand All @@ -74,10 +67,6 @@ deepDealias tipe =
deepDealias (dealias args tipe')
TType home name args ->
TType home name (map deepDealias args)
TUnit ->
TUnit
TTuple a b c ->
TTuple (deepDealias a) (deepDealias b) (fmap deepDealias c)

deepDealiasField :: FieldType -> FieldType
deepDealiasField (FieldType index tipe) =
Expand Down
11 changes: 0 additions & 11 deletions compiler/src/Canonicalize/Effects.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,6 @@ checkPayload tipe =
| isArray home name -> checkPayload arg
_ ->
Left (tipe, Error.UnsupportedType name)
Can.TUnit ->
Right ()
Can.TTuple a b maybeC ->
do
checkPayload a
checkPayload b
case maybeC of
Nothing ->
Right ()
Just c ->
checkPayload c
Can.TVar name ->
Left (tipe, Error.TypeVariable name)
Can.TLambda _ _ ->
Expand Down
8 changes: 0 additions & 8 deletions compiler/src/Canonicalize/Environment/Local.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ getEdges edges (A.At _ tipe) =
List.foldl' getEdges edges args
Src.TRecord fields _ ->
List.foldl' (\es (_, t) -> getEdges es t) edges fields
Src.TUnit ->
edges
Src.TTuple a b cs ->
List.foldl' getEdges (getEdges (getEdges edges a) b) cs

-- CHECK FREE VARIABLES

Expand Down Expand Up @@ -199,10 +195,6 @@ addFreeVars freeVars (A.At region tipe) =
Just (A.At extRegion ext) ->
Map.insert ext extRegion freeVars
in List.foldl' (\fvs (_, t) -> addFreeVars fvs t) extFreeVars fields
Src.TUnit ->
freeVars
Src.TTuple a b cs ->
List.foldl' addFreeVars (addFreeVars (addFreeVars freeVars a) b) cs

-- ADD CTORS

Expand Down
26 changes: 0 additions & 26 deletions compiler/src/Canonicalize/Expression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,6 @@ canonicalize env (A.At region expression) =
do
fieldDict <- Dups.checkFields fields
Can.Record <$> traverse (canonicalize env) fieldDict
Src.Unit ->
Result.ok Can.Unit
Src.Tuple a b cs ->
Can.Tuple
<$> canonicalize env a
<*> canonicalize env b
<*> canonicalizeTupleExtras region env cs

-- CANONICALIZE TUPLE EXTRAS

canonicalizeTupleExtras :: A.Region -> Env.Env -> [Src.Expr] -> Result FreeLocals [W.Warning] (Maybe Can.Expr)
canonicalizeTupleExtras region env extras =
case extras of
[] ->
Result.ok Nothing
[three] ->
Just <$> canonicalize env three
_ ->
Result.throw (Error.TupleLargerThanThree region)

-- CANONICALIZE IF BRANCH

Expand Down Expand Up @@ -262,10 +243,6 @@ addBindingsHelp bindings (A.At region pattern) =
Dups.insert name region region bindings
Src.PRecord fields ->
List.foldl' addBindingsHelp bindings (map extractRecordFieldPattern fields)
Src.PUnit ->
bindings
Src.PTuple a b cs ->
List.foldl' addBindingsHelp bindings (a : b : cs)
Src.PCtor _ _ patterns ->
List.foldl' addBindingsHelp bindings patterns
Src.PCtorQual _ _ _ patterns ->
Expand Down Expand Up @@ -377,8 +354,6 @@ getPatternNames names (A.At region pattern) =
Src.PRecord fields ->
List.foldl' (\n f -> getPatternNames n (extractRecordFieldPattern f)) names fields
Src.PAlias ptrn name -> getPatternNames (name : names) ptrn
Src.PUnit -> names
Src.PTuple a b cs -> List.foldl' getPatternNames (getPatternNames (getPatternNames names a) b) cs
Src.PCtor _ _ args -> List.foldl' getPatternNames names args
Src.PCtorQual _ _ _ args -> List.foldl' getPatternNames names args
Src.PArray patterns -> List.foldl' getPatternNames names patterns
Expand Down Expand Up @@ -487,7 +462,6 @@ logVar name value =
Result.Result $ \freeLocals warnings _ good ->
good (Map.insertWith combineUses name oneDirectUse freeLocals) warnings value

{-# NOINLINE oneDirectUse #-}
oneDirectUse :: Uses
oneDirectUse =
Uses 1 0
Expand Down
17 changes: 0 additions & 17 deletions compiler/src/Canonicalize/Pattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ canonicalize env (A.At region pattern) =
logVar name region (Can.PVar name)
Src.PRecord fields ->
Can.PRecord <$> canonicalizeRecordFields env fields
Src.PUnit ->
Result.ok Can.PUnit
Src.PTuple a b cs ->
Can.PTuple
<$> canonicalize env a
<*> canonicalize env b
<*> canonicalizeTuple region env cs
Src.PCtor nameRegion name patterns ->
canonicalizeCtor env region name patterns =<< Env.findCtor nameRegion env name
Src.PCtorQual nameRegion home name patterns ->
Expand Down Expand Up @@ -121,16 +114,6 @@ canonicalizeCtor env region name patterns ctor =
Env.RecordCtor _ _ _ ->
Result.throw (Error.PatternHasRecordCtor region name)

canonicalizeTuple :: A.Region -> Env.Env -> [Src.Pattern] -> Result DupsDict w (Maybe Can.Pattern)
canonicalizeTuple tupleRegion env extras =
case extras of
[] ->
Result.ok Nothing
[three] ->
Just <$> canonicalize env three
_ ->
Result.throw $ Error.TupleLargerThanThree tupleRegion

canonicalizeList :: Env.Env -> [Src.Pattern] -> Result DupsDict w [Can.Pattern]
canonicalizeList env list =
case list of
Expand Down
21 changes: 0 additions & 21 deletions compiler/src/Canonicalize/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,6 @@ canonicalize env (A.At typeRegion tipe) =
do
cfields <- sequenceA =<< Dups.checkFields (canonicalizeFields env fields)
return $ Can.TRecord cfields (fmap A.toValue ext)
Src.TUnit ->
Result.ok Can.TUnit
Src.TTuple a b cs ->
Can.TTuple
<$> canonicalize env a
<*> canonicalize env b
<*> case cs of
[] ->
Result.ok Nothing
[c] ->
Just <$> canonicalize env c
_ ->
Result.throw $ Error.TupleLargerThanThree typeRegion

canonicalizeFields :: Env.Env -> [(A.Located Name.Name, Src.Type)] -> [(A.Located Name.Name, Result i w Can.FieldType)]
canonicalizeFields env fields =
Expand Down Expand Up @@ -109,14 +96,6 @@ addFreeVars freeVars tipe =
Map.foldl addFieldFreeVars freeVars fields
Can.TRecord fields (Just ext) ->
Map.foldl addFieldFreeVars (Map.insert ext () freeVars) fields
Can.TUnit ->
freeVars
Can.TTuple a b maybeC ->
case maybeC of
Nothing ->
addFreeVars (addFreeVars freeVars a) b
Just c ->
addFreeVars (addFreeVars (addFreeVars freeVars a) b) c
Can.TAlias _ _ args _ ->
List.foldl' (\fvs (_, arg) -> addFreeVars fvs arg) freeVars args

Expand Down
Loading