hugs

How to use GADTs in Hugs

帅比萌擦擦* 提交于 2019-12-23 01:40:11
问题 I'd like to write a Haskell program that uses GADTs interactively on a platform not supported by GHCi (namely, GNU/Linux on mipsel). The problem is, the construct that can be used to define a GADT in GHC, for example: data Term a where Lit :: Int -> Term Int Pair :: Term a -> Term b -> Term (a,b) ... doesn't seem working on Hugs. Can't GADTs really be defined in Hugs? My TA at a Haskell class said it was possible in Hugs, but he seemed unsure. If not, can GADT be encoded by using other syntax

I can't do anything on Haskell due to syntax errors

若如初见. 提交于 2019-12-11 01:40:05
问题 I can execute simply operations, like Hugs> 2+2 for instance. Or any operation, for that matter. But when it comes to actually trying to define a function, e.g: occurs :: Eq a => a -> [a] -> Bool occurs x l = x `elem` l Then I get the message: ERROR - Syntax error in input (unexpected `=') I also get unexpected `::' in other cases. I'm using WinHugs. 回答1: When typing in a function in interactive mode, you need to use let , and you also have to separate lines with a semicolon: let occurs :: Eq

Why does this Show instance in Haskell (Hugs) cause a stack overflow error?

别来无恙 提交于 2019-12-10 18:29:50
问题 The following is a polymorphic data type in Haskell, interpreted by Hugs. I am trying to create an instance of Show for Equality. The instance declaration says that if a type "a" is in Show, then Equality a is in Show. It should print the two arguments to the constructor Equals a b in the form "a = b". data Equality a = Equals a a instance (Show a) => Show (Equality a) where show (Equals a b) = a ++ " = " ++ b Yet, typing something into Hugs like "(Equality 9 9)" yields: ERROR - C stack

Hugs !! Partial Application Bug

混江龙づ霸主 提交于 2019-12-07 02:01:05
问题 Hugs seems to have a problem with several non-enbraced !! in a partial application. While this works fine in GHCi: ([[0]]!!0!!)0 Hugs reports a syntax error for the ) . Is this a bug in Hugs? Adding an extra brace for the second list index operator works though: (([[0]]!!)0!!)0 or (([[0]]!!0)!!)0 回答1: This is a known issue in Hugs. From the Hugs 98 Users Guide section on Expressions: In Hugs, the expression must be an fexp (or case or do ). Legal expressions like (a+b+) and (a*b+) are

Hugs !! Partial Application Bug

时光总嘲笑我的痴心妄想 提交于 2019-12-05 06:15:50
Hugs seems to have a problem with several non-enbraced !! in a partial application. While this works fine in GHCi: ([[0]]!!0!!)0 Hugs reports a syntax error for the ) . Is this a bug in Hugs? Adding an extra brace for the second list index operator works though: (([[0]]!!)0!!)0 or (([[0]]!!0)!!)0 This is a known issue in Hugs. From the Hugs 98 Users Guide section on Expressions: In Hugs, the expression must be an fexp (or case or do ). Legal expressions like (a+b+) and (a*b+) are rejected. Digression Alert Maybe this is what FUZxxl was talking about in his comment? Try defining your own (!!)