Here is a transcript:
----------------
enescu:/nfs/isd/hdaume/stat-sum-ulf 54% ghci -package lang
ghci -package lang
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 5.00.2, For Haskell
98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package std ... linking ... done.
Loading package lang ... linking ... done.
Prelude> :l Util
:l Util
Skipping  Util             ( Util.hs, ./Util.o )
Ok, modules loaded: Util.
Util> List.[]
List.[]

Ambiguous type variable(s) `t' in the constraint `PrelShow.Show t'
arising from use of `PrelIO.print' at <No locn>
in a `do' expression pattern binding: PrelIO.print it
Util> `eq`
`eq`
<no file>:0: parse error on input ``'
Util> 3 `eq` 4
3 `eq` 4

<no file>:0: Variable not in scope: `eq'
Util> :l Util
:l Util
unloadObj: can't find `./Util.o' to unload
ghc-5.00.2: panic! (the `impossible' happened, GHC version 5.00.2):
        unloadObj: failed

Please report it as a compiler bug to [EMAIL PROTECTED],
or http://sourceforge.net/projects/ghc/.


Util> 
-------------

I'm not sure exactly what went wrong, but here's a copy of Util.hs...

-- 
Hal Daume III

 "Computer science is no more about computers    | [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
module Util
    where

import List
import Maybe
import Char
import IO
import IOExts

infix !=

a != b = not (a == b)

nth [] i = error ("nth out of range: " ++ (show i))
nth (x:_) 1 = x
nth (_:x) (n+1) = nth x n

containsFn f l = isJust (find f l)

contains x = containsFn (==x)

mapPartial :: (a -> Maybe b) -> [a] -> [b]
mapPartial f l = mapPartial' f l []
    where mapPartial' _ [] acc = acc
          mapPartial' f (x:xs) acc = mapPartial' f xs (case f x of
                                                       Nothing -> acc
                                                       Just x' -> x':acc)

-- same as otherwise
ow = True

foldMaybe :: (a -> b -> Maybe a) -> a -> [b] -> Maybe a
foldMaybe _ a [] = Just a
foldMaybe f a (b:bs) = case f a b of
                         Nothing -> Nothing
                         Just a' -> foldMaybe f a' bs

allButLast :: [a] -> [a]
allButLast [] = error "allButLast on []"
allButLast [x] = []
allButLast (x:xs) = x:allButLast xs

putErr s = unsafePerformIO (do hPutStrLn stderr s)

maybeGood Nothing  = Error "maybeGood"
maybeGood (Just a) = Good a

goodMaybe (Error _) = Nothing
goodMaybe (Good a)  = Just a

infixr 9 ===, =~=

good (Good a) = a
good (Error err) = error err

class LCaseEq a where
    (===) :: a -> a -> Bool

instance LCaseEq Char where
    c1 === c2 = toLower c1 == toLower c2

instance LCaseEq a => LCaseEq [a] where
    [] === [] = True
    [] === _  = False
    _  === [] = False
    (c:cs) === (c':cs') = c === c' && cs === cs'

class Approx a where
    (=~=) :: a -> a -> Bool

instance Eq a => Approx [a] where
    a =~= b = take 50 a == take 50 b

data Errored a = Good a | Error String
             deriving (Eq, Show, Ord, Read)


isNum x = isAlphaNum x && (not (isAlpha x))

--beginsWithBy "abc" "abcd" (==) = True
--beginsWithBy "abc" "ab"   (==) = False
beginWithBy _ [] _ = True
beginWithBy _ _ [] = False
beginWithBy eq (x:xs) (y:ys) | x `eq` y  = beginWithBy xs ys eq
                             | otherwise = False

beginWith = beginWithBy (==)

Reply via email to