Advertisement Jump to content
Sign in to follow this  

haskell and prolog

This topic is 5050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi there. i have to do an assignment in these two langiages, ive looked for the compilers and only found one for haskell the ghc or something, this however doesnt seem to work, ive installed it and when i run it a dos screen pops up and disapears immediatly. can any of you guys give me a definate link to a working compi;ler for both these langauges it will be greatly appreciated. i dont know anything about these things so i need direct help please thanks people

Share this post

Link to post
Share on other sites
What is probably happening is that you aren't providing the required parameters when you run your Haskell compiler, so the compiler issues an error message and exits. Because the compiler exits, the DOS window shuts and you don't get to read the error message.

Try running it in a dos window (Start menu->Run->"command"). Then the window won't close when the compiler does.

Here's the standard prolog interpreter.

Share this post

Link to post
Share on other sites
hi ive just typed in what all the help files i have looked at claim are the way you state a function in haskell, the line was

testWord = "testing" and i get
:ERROR - Syntax error in input (unexpected `=')

how do i make testWord = "testing"?

i dont understand

Share this post

Link to post
Share on other sites
that is a correct haskell function, but you can't define functions in the interpreter. You need to create them in a file, and then load them.


testWord :: String
testWord = "testing"

in hugs:
> :l foo.hs
> testWord

(you don't have to define the types of functions, but it is good practice.)


Share this post

Link to post
Share on other sites
Day 3 of learn haskell.

Ive looked at a load of tutorials and quite frankly im fed up of reversing strings and removing certain characters from them

What i need is to (ill explain this how i would in pascal, c or c++, i know haskel does not work like this)

i need to create a record that holds say a name ::string, age :: int, on/off :: bool

how do i store something like this and then use a function to get the name of the thing, its age and is it turned on or off.

how would i answer a question like. is archibold turned on?


Share this post

Link to post
Share on other sites
something like this, perhaps..

data Record = Record {
name :: String,
age :: Int,
onoff :: Bool}

myrecord = Record {
name = "Nico",
age = 666,
onoff = True}

myfunc :: Record -> String
myfunc rec = let r_name = name rec;
r_age = age rec;
r_onoff = onoff rec; in
"Name: " ++ r_name ++ "\nAge: " ++ (show r_age) ++ "\nOn: " ++ (show r_onoff)

just remember you can't have truly mutable varibles in haskell without monads.

hope it helps..

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!