BD107
BD107

Reputation: 159

`MonadThrow` Not in scope beginning at LTS 11.0

I've found that using

me$ stack install --resolver lts-11.0 on the snippet

{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where

import ClassyPrelude
import Network.HTTP.Conduit (host)

hostnameFromUrl :: MonadThrow m => Text -> m Text
hostnameFromUrl url = do
    return $ decodeUtf8 $ host "helloworld.com"

fails with message

/Users/me/.../temp/Main.hs:8:20: error:
    Not in scope: type constructor or class ‘MonadThrow’
  |
8 | hostnameFromUrl :: MonadThrow m => Text -> m Text
  |                    ^^^^^^^^^^

when any lts >= 11.0 is used. No error is raised for lts <= 10.10.

This seems strange, as the relevant package (exceptions-0.8.3) does not change between these two LTSs.

I have stack.yaml file

resolver: lts-11.0
packages:
  - '.'
flags: {}
extra-package-dbs: []

and temp.cabal file

name:                temp
version:             0.0
build-type:          Simple
-- extra-source-files:
cabal-version:       >=1.10

library
  hs-source-dirs:      .
  exposed-modules:     Main
  ghc-options:         -Wall
  build-depends:       classy-prelude >= 1.0.0.2
                     , http-conduit >= 2.1
  default-language:    Haskell2010

Pardon the specific setup; I've tried to make this as easily replicable as possible.

Any insight would be greatly appreciated! Thank you.

Upvotes: 1

Views: 137

Answers (1)

Michael Snoyman
Michael Snoyman

Reputation: 31345

It's no longer exported from ClassyPrelude, you'd need to import it from Control.Monad.Catch.

Upvotes: 4

Related Questions