Skip to content

Commit

Permalink
Added core constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
justingrubbs committed May 24, 2024
1 parent bf626c5 commit 28447b9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/Disco/AST/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ data Op
| -- | Not the Boolean `Impl`, but instead a propositional BOp
-- | Should only be seen and used with Props.
OImpl
| -- | Cool
OSeed
| -- | Cool
ORandom
deriving (Show, Generic, Data, Alpha, Eq, Ord)

-- | Get the arity (desired number of arguments) of a function
Expand Down Expand Up @@ -404,3 +408,6 @@ opToStr = \case
OAnd -> "and"
OOr -> "or"
OImpl -> "implies"

ORandom -> "random"
OSeed -> "seed"
4 changes: 2 additions & 2 deletions src/Disco/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ compilePrim ty PrimConnect = compilePrimErr PrimConnect ty
compilePrim _ PrimInsert = return $ CConst OInsert
compilePrim _ PrimLookup = return $ CConst OLookup

-- compilePrim _ PrimRandom = return $ CConst ORandom
-- compilePrim _ PrimSeed = return $ CConst OSeed
compilePrim _ PrimRandom = return $ CConst ORandom
compilePrim _ PrimSeed = return $ CConst OSeed

compilePrim (_ :*: TyList _ :->: _) PrimEach =
return $
Expand Down
13 changes: 2 additions & 11 deletions src/Disco/Typecheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -771,17 +771,8 @@ typecheck Infer (TPrim prim) = do
----------------------------------------
-- Randomness

-- inferPrim PrimRandom = return $ TyGen :*: (TyN :*: TyN) :->: (TyGen :*: TyN)
-- inferPrim PrimSeed = return $ TyN :->: TyGen

inferPrim PrimRandom = do
a <- freshTy
constraint $ CQual QNum a
return $ TyGen :*: (a :*: a) :->: (TyGen :*: a)
inferPrim PrimSeed = do
a <- freshTy
constraint $ CQual QNum a
return $ a :->: TyGen
inferPrim PrimRandom = return $ TyGen :*: (TyN :*: TyN) :->: (TyGen :*: TyN)
inferPrim PrimSeed = return $ TyN :->: TyGen

----------------------------------------
-- Arithmetic
Expand Down
2 changes: 1 addition & 1 deletion src/Disco/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ instance Pretty BaseTy where
CtrBag -> text "Bag"
CtrSet -> text "Set"

Gen -> text "gen"
Gen -> text "Gen"

-- | Test whether a 'BaseTy' is a container (set, bag, or list).
isCtr :: BaseTy -> Bool
Expand Down

0 comments on commit 28447b9

Please sign in to comment.