シリーズ: haskell
haskell
57 行
· 更新日 2026-02-03
Type.hs
haskell/Week9/Type.hs
{-|
Module : Type
Author : COMP1100 Team, Your name and UID here
Date :
Description : Exercises with types
-}
module Type where
{-
Exercise 1: (Optional)
Work out the type classes for the following types.
The first one has been done for you.
Integer (Integral)
Double (?)
Char (?)
Bool (?)
(Integer, Integer) (?)
(Integer, Double) (?)
String (?)
[Integer] (?)
Integer -> Integer (?)
Maybe Integer (?)
-}
{-
Exercise 2:
What are the types of these functions?
(Don't just cheat and punch it in GHCi. Try to work it out yourself.)
-}
--cow :: ???
cow :: Bool -> Char -> String -> Bool
cow x y z = x && (elem y z)
--foo :: ???
foo :: Char -> String -> [String] -> Bool
foo x y z = (elem x y) && (elem y z)
--bar :: ???
bar :: Num a => a -> Maybe a -> a
bar x y = case y of
Nothing -> x
Just z -> x + z
-- snap :: ???
snap :: (Show a, Ord a) => a -> a -> String
snap x y
| x > y = show x
| otherwise = show y
関連記事
haskell
haskell
更新日 2026-02-03
Adding.hs
Adding.hs — haskell source code from the haskell learning materials (haskell/Adding.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Area.hs
Area.hs — haskell source code from the haskell learning materials (haskell/Area.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Chess.hs
Chess.hs — haskell source code from the haskell learning materials (haskell/Chess.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
ChessGraphics.hs
ChessGraphics.hs — haskell source code from the haskell learning materials (haskell/ChessGraphics.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Examples.hs
Examples.hs — haskell source code from the haskell learning materials (haskell/Examples.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Fibonacci.hs
Fibonacci.hs — haskell source code from the haskell learning materials (haskell/Fibonacci.hs).
記事を読む →