__ __ __ __ ____ ___ _______________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2005 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Bugs: http://hackage.haskell.org/trac/hugs || || Version: Sep 2006 _______________________________________________ Haskell 98 mode: Restart with command line option -98 to enable extensions Type :? for help Main> :edit Main> :r Main> strToFn "plus" ERROR - Cannot find "show" function for: *** Expression : strToFn "plus" *** Of type : Integer -> Integer -> Integer Main> (strToFn "plus") 5 7 12 Main> (buildStringEnder ", eh?") "hello" "hello, eh?" Main> \x -> x * 5 ERROR - Cannot find "show" function for: *** Expression : \x -> x * 5 *** Of type : Integer -> Integer Main> :r Main> safeSqrt 100 10.0 Main> :type safeSqrt safeSqrt :: Floating a => a -> a Main> ( (\x->x+1) . (\y->y*2) ) 100 201 Main> sqrt . abs 10 ERROR - Cannot infer instance *** Instance : Num (b -> a) *** Expression : sqrt . abs 10 Main> applyToAll (+1) [2,3,4,5,6] [3,4,5,6,7] Main> applyToAll (\n->n*n) [2,3,4,5,6] [4,9,16,25,36] Main> map (+1) [1..10] [2,3,4,5,6,7,8,9,10,11] Main> :r Main> keep even [0..10] ERROR - Cannot find "show" function for: *** Expression : keep even (enumFromTo 0 10) *** Of type : [Integer -> Bool] Main> keep (even) [0..10] ERROR - Cannot find "show" function for: *** Expression : keep even (enumFromTo 0 10) *** Of type : [Integer -> Bool] Main> :r Main> keep (even) [0..10] [0,2,4,6,8,10] Main> keep (\l->length l <= 2) [[1,2,3], [4,5], [8], [3,4,5,6]] [[4,5],[8]] Main> :type keep keep :: (a -> Bool) -> [a] -> [a] Main> filter (\l->length l <= 2) [[1,2,3], [4,5], [8], [3,4,5,6]] [[4,5],[8]] Main> :r Main> :r Main> largest [1,2,3] ERROR - Cannot infer instance *** Instance : Num [a] *** Expression : largest [1,2,3] Main> :r Main> :type reduce reduce :: (a -> a -> a) -> [a] -> a Main> :type foldr1 foldr1 :: (a -> a -> a) -> [a] -> a Main> foldr1 (\l1 l2->if (length l1) > (length l2) then l1 else l2) [[1,2],[3,4]] [3,4] Main> :type foldr foldr :: (a -> b -> b) -> b -> [a] -> b Main> foldr (\n m->n) (error "hello") [2,3,4] 2 Main> foldr (\n m->n) (error "hello") [] Program error: hello Main> foldr (\n ->n m) (error "hello") [2,3,4] ERROR - Undefined variable "m" Main> foldr (\n m-> m) (error "hello") [2,3,4] Program error: hello Main>