Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Haskell Help Rate Topic: -----

#1 User is offline   Man2u2uk

  • W.R. Lieutenant
  • Icon
  • Group: Members
  • Posts: 396
  • Joined: 14-April 07
  • Gender:Male

Posted 22 June 2008 - 06:26 AM

Hi All,

I am trying to make a small haskell program that defines all logic gates AND, OR, NAND, NOR, XOR, NOT

For some reason the not function works on its own, but when i put it with the following code below, i get the following error. i have tried everything, and googled alot, but haskell is not that popular on the search engines :(

I would be greatful if someone could help me on this, thanks in advance

Syntax error in input (unexpected `=`)

> and :: Bool -> Bool -> Bool 
> and a b = a&&b


> or :: Bool -> Bool -> Bool
> or a b = a||b


> not :: Bool -> Bool
> not True = False
> not False = True


> nand :: Bool -> Bool -> Bool
> nand a b = not ( a `and` b )


> nor :: Bool -> Bool -> Bool
> nor a b = not ( a `and` b )

> xor :: Bool -> Bool -> Bool
> xor a b = ( a `or` b ) `and` (not ( a `and` b ))

0

#2 User is offline   Sirkent

  • Loose bits sink chips
  • Icon
  • Group: Administrators
  • Posts: 2,101
  • Joined: 04-April 06
  • Gender:Male
  • Location:Kent, UK

Posted 24 June 2008 - 05:40 AM

I've been trying to remember my Haskell from University. I think the problem is that main.hs (which is included by default) has functions named the same as the ones you're trying to declare. You can either rename the functions or there is a way to exclude main.hs instead. I'm afraid I can't remember how to exclude it!
QUOTE(benbramz @ Aug 17 2007, 07:44 AM) <{POST_SNAPBACK}>
Ive noticed that quite a few people are now adding quotes from the board into their signature. I think its started an new web-radiance craze.. :P
0

#3 User is offline   Man2u2uk

  • W.R. Lieutenant
  • Icon
  • Group: Members
  • Posts: 396
  • Joined: 14-April 07
  • Gender:Male

Posted 24 June 2008 - 06:20 AM

Thanks for replying.

Yes you are correct, i found out a few days ago that i had to do the following :)

> module Main where
> import Prelude hiding (and, or, not)

This post has been edited by Man2u2uk: 24 June 2008 - 06:21 AM

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users