Skip to content

Commit

Permalink
Restyled by fourmolu (#1803)
Browse files Browse the repository at this point in the history
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
restyled-io[bot] and restyled-commits authored Apr 25, 2024
1 parent 4228e3e commit e0e0ab8
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/swarm-lang/Swarm/Effect/Unify/Fast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import Data.Function (on)
import Data.Map qualified as M
import Data.Map.Merge.Lazy qualified as M
import Data.Set qualified as S
import Prelude hiding (lookup)
import Swarm.Effect.Unify
import Swarm.Effect.Unify.Common
import Swarm.Language.Types hiding (Type)
import Prelude hiding (lookup)

------------------------------------------------------------
-- Substitutions
Expand Down Expand Up @@ -70,22 +70,22 @@ class Substitutes n b a where
-- over a structure functor @f@.
instance Substitutes IntVar UType UType where
subst s f = go S.empty f
where
go seen (Pure x) = case lookup x s of
Nothing -> pure $ Pure x
Just t
| S.member x seen -> throwError $ Infinite x t
| otherwise -> go (S.insert x seen) t
go seen (Free t) = Free <$> goF seen t

goF _ t@(TyBaseF {}) = pure t
goF _ t@(TyVarF {}) = pure t
goF seen (TySumF t1 t2) = TySumF <$> go seen t1 <*> go seen t2
goF seen (TyProdF t1 t2) = TyProdF <$> go seen t1 <*> go seen t2
goF seen (TyRcdF m) = TyRcdF <$> mapM (go seen) m
goF seen (TyCmdF c) = TyCmdF <$> go seen c
goF seen (TyDelayF c) = TyDelayF <$> go seen c
goF seen (TyFunF t1 t2) = TyFunF <$> go seen t1 <*> go seen t2
where
go seen (Pure x) = case lookup x s of
Nothing -> pure $ Pure x
Just t
| S.member x seen -> throwError $ Infinite x t
| otherwise -> go (S.insert x seen) t
go seen (Free t) = Free <$> goF seen t

goF _ t@(TyBaseF {}) = pure t
goF _ t@(TyVarF {}) = pure t
goF seen (TySumF t1 t2) = TySumF <$> go seen t1 <*> go seen t2
goF seen (TyProdF t1 t2) = TyProdF <$> go seen t1 <*> go seen t2
goF seen (TyRcdF m) = TyRcdF <$> mapM (go seen) m
goF seen (TyCmdF c) = TyCmdF <$> go seen c
goF seen (TyDelayF c) = TyDelayF <$> go seen c
goF seen (TyFunF t1 t2) = TyFunF <$> go seen t1 <*> go seen t2

------------------------------------------------------------
-- Carrier type
Expand Down Expand Up @@ -178,7 +178,9 @@ unifyVar ::
( Has (Throw UnificationError) sig m
, Has (State (Subst IntVar UType)) sig m
) =>
IntVar -> UType -> m UType
IntVar ->
UType ->
m UType
unifyVar x (Pure y) = do
myv <- lookupS y
case myv of
Expand Down

0 comments on commit e0e0ab8

Please sign in to comment.