Permalink
Browse files

Casting.

  • Loading branch information...
leepike committed Nov 5, 2011
1 parent 7eb2b9d commit 25df4bf29ae3cf5ab9eb59abb4efaae94b383c51
Showing with 5 additions and 1 deletion.
  1. +1 −0 src/Copilot/Core/Interpret/Eval.hs
  2. +3 −1 src/Copilot/Core/Operators.hs
  3. +1 −0 src/Copilot/Core/PrettyPrint.hs
@@ -181,6 +181,7 @@ evalOp1 op = case op of
Atanh _ -> P.atanh
Acosh _ -> P.acosh
BwNot _ -> complement
+ Cast _ _ -> P.fromIntegral
--------------------------------------------------------------------------------
@@ -40,8 +40,10 @@ data Op1 a b where
Asinh :: Floating a => Type a -> Op1 a a
Atanh :: Floating a => Type a -> Op1 a a
Acosh :: Floating a => Type a -> Op1 a a
- -- Bitwise operators:
+ -- Bitwise operators.
BwNot :: Bits a => Type a -> Op1 a a
+ -- Casting operaators.
+ Cast :: (Integral a, Num b) => Type a -> Type b -> Op1 a b
-- | Binary operators.
data Op2 a b c where
@@ -68,6 +68,7 @@ ppOp1 op = case op of
Atanh _ -> ppPrefix "atanh"
Acosh _ -> ppPrefix "acosh"
BwNot _ -> ppPrefix "~"
+ Cast _ _ -> ppPrefix "(cast)"
ppOp2 :: Op2 a b c -> Doc -> Doc -> Doc
ppOp2 op = case op of

0 comments on commit 25df4bf

Please sign in to comment.