Skip to content
AtomicReps

Navigation

24/29Computer Science

Haskell.

The functional-programming course: types, purity, laziness and the classes that tie them together.

  • Haskell · 1 of 3

    Types and signatures

    What type does a bare whole number literal have here?

    typescript
    -- GHC 9.6.7, ghci :type. Literals and the arithmetic over them.1                     :: Num a => a1.5                   :: Fractional a => a1 + 2                 :: Num a => a7 / 2                 :: Fractional a => adiv 7 2               :: Integral a => atruncate 3.7          :: Integral b => bfromIntegral (3::Int) :: Num b => blength [1,2,3]        :: Int
  • Haskell · 2 of 3

    Types and signatures

    Flipping subtraction and supplying one side. What is left?

    typescript
    -- GHC 9.6.7, ghci :type. What is left after some arguments are supplied.map (*2)            :: Num b => [b] -> [b]foldr (+)           :: (Foldable t, Num b) => b -> t b -> bfoldr (+) 0         :: (Foldable t, Num b) => t b -> bzipWith (+) [1,2,3] :: Num c => [c] -> [c](+) 1               :: Num a => a -> aflip (-) 1          :: Num c => c -> c(.) show            :: Show b => (a -> b) -> a -> String
  • Haskell · 3 of 3

    Types and signatures

    Why is one expression in the numeric listing concrete while everything around it is not?

    typescript
    -- GHC 9.6.7, ghci :type. Literals and the arithmetic over them.1                     :: Num a => a1.5                   :: Fractional a => a1 + 2                 :: Num a => a7 / 2                 :: Fractional a => adiv 7 2               :: Integral a => atruncate 3.7          :: Integral b => bfromIntegral (3::Int) :: Num b => blength [1,2,3]        :: Int

Three of the 1,200 Haskell questions.

Keep going with Haskell, free
Next topic · 25/29Networking.