mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
fix the pattern matching in unStr, unInt, unDouble
This commit is contained in:
@@ -112,6 +112,7 @@ mkStr s = ELit (LStr s)
|
|||||||
-- | Decomposes an expression into string literal
|
-- | Decomposes an expression into string literal
|
||||||
unStr :: Expr -> Maybe String
|
unStr :: Expr -> Maybe String
|
||||||
unStr (ELit (LStr s)) = Just s
|
unStr (ELit (LStr s)) = Just s
|
||||||
|
unStr _ = Nothing
|
||||||
|
|
||||||
-- | Constructs an expression from integer literal
|
-- | Constructs an expression from integer literal
|
||||||
mkInt :: Integer -> Expr
|
mkInt :: Integer -> Expr
|
||||||
@@ -120,6 +121,7 @@ mkInt i = ELit (LInt i)
|
|||||||
-- | Decomposes an expression into integer literal
|
-- | Decomposes an expression into integer literal
|
||||||
unInt :: Expr -> Maybe Integer
|
unInt :: Expr -> Maybe Integer
|
||||||
unInt (ELit (LInt i)) = Just i
|
unInt (ELit (LInt i)) = Just i
|
||||||
|
unInt _ = Nothing
|
||||||
|
|
||||||
-- | Constructs an expression from real number literal
|
-- | Constructs an expression from real number literal
|
||||||
mkDouble :: Double -> Expr
|
mkDouble :: Double -> Expr
|
||||||
@@ -128,6 +130,7 @@ mkDouble f = ELit (LFlt f)
|
|||||||
-- | Decomposes an expression into real number literal
|
-- | Decomposes an expression into real number literal
|
||||||
unDouble :: Expr -> Maybe Double
|
unDouble :: Expr -> Maybe Double
|
||||||
unDouble (ELit (LFlt f)) = Just f
|
unDouble (ELit (LFlt f)) = Just f
|
||||||
|
unDouble _ = Nothing
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
-- Parsing
|
-- Parsing
|
||||||
|
|||||||
Reference in New Issue
Block a user