haskell

How to install an older version of base in Haskell

让人想犯罪 __ 提交于 2021-01-27 06:40:09
问题 I have installed Haskell platform and I have the 7.10.3 version of ghci, which has the 4.8.2.0 version of base. I need to install gloss-1.8.* which needs base-4.7.* version of base. My question is how to install this older version now, when I already have the newer version. Is it possible? Or do I have to uninstall the Haskell platform and install an older version? 来源: https://stackoverflow.com/questions/37195188/how-to-install-an-older-version-of-base-in-haskell

Pandoc 'Could not find module …' for installed module

倾然丶 夕夏残阳落幕 提交于 2021-01-27 06:31:36
问题 I'm currently trying to use pandoc (as a Haskell module, not as a program) to convert MediaWiki text to other formats. Let's assume this program: import Text.Pandoc.Readers.MediaWiki main = do print "foo" When using runghc to run it, I get the following error message: pandock.hs:1:8: Could not find module `Text.Pandoc.Readers.MediaWiki' Use -v to see a list of the files searched for. My first assumption was that pandoc was either not installed or incorrectly installed. Therefore I reinstalled

COMPLETE pragma doesn't prevent incomplete-patterns warning

点点圈 提交于 2021-01-27 06:09:31
问题 I made two pattern views for a list-like class. infixr 5 :< pattern (:<) :: Stream s => Token s -> s -> s pattern b :< bs <- (uncons -> Just (b, bs)) where b :< bs = cons b bs pattern Nil :: Stream s => s pattern Nil <- (uncons -> Nothing) where Nil = empty uncons signature: uncons :: (Stream s) => s -> Maybe (Token s, s) . Suppose I also have function that uses these patterns like that: foo (b:<bs) = … foo Nil = … It's obvious in this case that pattern matches are exhaustive, and I would

Building multiple executables in the default Haskell Stack project

不羁的心 提交于 2021-01-27 05:45:00
问题 I used the default stack new to setup a project that has a server and a client as separate executables. I altered the package.yaml file in what seems like the right way (As of April 21, 2020 "There is no user guide") and added a new file to my app directory called Client.hs . I got an error saying "Enabling workaround for Main module 'Main' listed in 'other-modules' illegally!" How do I have stack build both the client and the server? When I ran stack build I got: [... clip ...] Building

Can I express a subclassing constraint?

帅比萌擦擦* 提交于 2021-01-27 05:09:16
问题 Still playing with existentials over constraints (just exploring this design space, I know it is considered bad by many Haskellers). See this question for more info. {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ConstraintKinds #-} {-# Language TypeApplications #-} import GHC.Exts (Constraint) class Foo a where foo :: a -> Int class Foo a => Bar a where bar :: a -> String instance Foo Int where foo = id instance Bar Int where bar = show data Obj cls =

Use list monad inside monad transformer type classes?

天大地大妈咪最大 提交于 2021-01-27 05:02:15
问题 My goal is to create a function that uses the list monad inside either a ReaderT WriterT stack, or a RWS stack. More generally, how do I use the list monad inside mtl typeclasses such as MonadReader, MonadWriter? Why am I trying to do this? This problem is an exercise in Beginning Haskell. It asks me to "use functionality from both MonadReader and MonadWriter wrapping the base list monad. To check that the function is general, use two different monads to [test] the requested functionality:

Are there algebraic data types outside of sum and product?

倾然丶 夕夏残阳落幕 提交于 2021-01-27 04:32:22
问题 By most definitons the common or basic algebraic data types in Haskell or Scala are sum and product. Examples: 1, 2. Sometimes a definition just says algebraic data types are sum and product, perhaps for simplicity. However, the definitions leave an impression that other algebraic data types are possible, and sum and product are just the most useful to describe selection or combination of elements. Given there are subtraction, division, raising to an integer power operations in a basic

Why do the types in `(fmap . fmap) sum Just [1, 2, 3]` work?

戏子无情 提交于 2021-01-27 03:55:33
问题 I'm having the time of my life reading the wonderful Haskell Programming from first principles and I came by the following example that I'm just not able to take apart (Page 1286 e-reader): Prelude> (fmap . fmap) sum Just [1, 2, 3] Just 6 It is obvious to me how the following works: Prelude> fmap sum $ Just [1,2,3] Just 6 And I already manually deconstructed (fmap . fmap) to understand how the types work. But when thinking about this as "lifting twice" it doesn't make sense, since I'm lifting

Why do the types in `(fmap . fmap) sum Just [1, 2, 3]` work?

爱⌒轻易说出口 提交于 2021-01-27 03:55:10
问题 I'm having the time of my life reading the wonderful Haskell Programming from first principles and I came by the following example that I'm just not able to take apart (Page 1286 e-reader): Prelude> (fmap . fmap) sum Just [1, 2, 3] Just 6 It is obvious to me how the following works: Prelude> fmap sum $ Just [1,2,3] Just 6 And I already manually deconstructed (fmap . fmap) to understand how the types work. But when thinking about this as "lifting twice" it doesn't make sense, since I'm lifting

In GHCi, why can't I show `pure 1` in REPL?

元气小坏坏 提交于 2021-01-27 03:51:45
问题 I tried to assign a lifted value to a . λ> :m Control.Applicative λ> let a = pure 1 When I evaluated a in REPL, it prints 1 . λ> a 1 Therefore, I thought there may be an implementation of show for a , and tried this: λ> show a But the GHCi throws an error: <interactive>:70:1-4: No instance for (Show (f0 a0)) arising from a use of ‘show’ The type variables ‘f0’, ‘a0’ are ambiguous Note: there are several potential instances: instance (Integral a, Show a) => Show (GHC.Real.Ratio a) -- Defined