From aquagnu at gmail.com Fri Dec 1 11:57:56 2017 From: aquagnu at gmail.com (Baa) Date: Fri, 1 Dec 2017 13:57:56 +0200 Subject: [Haskell-beginners] Overlapping instances problem Message-ID: <20171201135756.5ac0c43d@Pavel> Hello, List! I got error: Duplicate instance declarations: instance [overlap ok] EnumTag a => Read a -- Defined at /XXX/intero/intero2932Xpa-TEMP.hs:110:27 instance [overlap ok] StrTag a => Read a -- Defined at /XXX/intero/intero2932Xpa-TEMP.hs:121:27 (intero) For this code: class (Show a, Enum a) => EnumTag a where anyEnum :: a instance {-# OVERLAPS #-} EnumTag a => Read a where readPrec = RP.lift P.skipSpaces >> expectEnum instance {-# OVERLAPS #-} EnumTag a => Eq a where a == b | a == anyEnum || b == anyEnum = True | otherwise = fromEnum a == fromEnum b class StrTag a where anyStr :: a tagPrefix :: a -> String -- ^ should be constant toStr :: String -> a instance {-# OVERLAPS #-} StrTag a => Read a where readPrec = parens $ do RP.lift P.skipSpaces (RP.lift $ expectShown anyStr) <++ RP.lift g where g = do Just s@(_:_) <- L.stripPrefix tagPrefix <$> expectTag return $ toStr s Why does it happen? `Read a` in 1st instance is valid only when a is `EnumTag`, in 2nd one - is valid only when a is `StrTag`. How can I fix this error and to create "default" instances for `EnumTag` and to `StrTag`, so client code will "inherit" those functionality (`Read`) simple, only with instantiation of `EnumTag` or `StrTag` ? Sure, if I comment `instance ... StrTag a` then all work fine, but I need 2 specialized `Read`s (and `Eq`s too :) === Best regards, Paul From toad3k at gmail.com Fri Dec 1 13:28:30 2017 From: toad3k at gmail.com (David McBride) Date: Fri, 1 Dec 2017 08:28:30 -0500 Subject: [Haskell-beginners] Overlapping instances problem In-Reply-To: <20171201135756.5ac0c43d@Pavel> References: <20171201135756.5ac0c43d@Pavel> Message-ID: What happens if type 'a' is both an instance EnumTag and StrTag at the same time? Then which instance does it choose? You may know that can't happen in your code, but there's no guarantee that someone using your library or that some import won't bring such a type into scope. Because of this ambiguity, during type checking haskell ignores class contexts and merely looks at the instance head (Read a), and says hey there are two instances 'Read a', they are overlapping. As to what to do about it, I'm not sure. But I don't think I would be trying to get different read instances based on whatever typeclasses happen to be in scope for that type. On Fri, Dec 1, 2017 at 6:57 AM, Baa wrote: > Hello, List! > > I got error: > > Duplicate instance declarations: > instance [overlap ok] EnumTag a => Read a > -- Defined at /XXX/intero/intero2932Xpa-TEMP.hs:110:27 > instance [overlap ok] StrTag a => Read a > -- Defined at /XXX/intero/intero2932Xpa-TEMP.hs:121:27 (intero) > > For this code: > > class (Show a, Enum a) => EnumTag a where > anyEnum :: a > > instance {-# OVERLAPS #-} EnumTag a => Read a where > readPrec = RP.lift P.skipSpaces >> expectEnum > instance {-# OVERLAPS #-} EnumTag a => Eq a where > a == b | a == anyEnum || b == anyEnum = True > | otherwise = fromEnum a == fromEnum b > > class StrTag a where > anyStr :: a > tagPrefix :: a -> String -- ^ should be constant > toStr :: String -> a > > instance {-# OVERLAPS #-} StrTag a => Read a where > readPrec = parens $ do > RP.lift P.skipSpaces > (RP.lift $ expectShown anyStr) <++ RP.lift g > where g = do > Just s@(_:_) <- L.stripPrefix tagPrefix <$> expectTag > return $ toStr s > > Why does it happen? `Read a` in 1st instance is valid only when a is > `EnumTag`, in 2nd one - is valid only when a is `StrTag`. > > How can I fix this error and to create "default" instances for `EnumTag` > and to `StrTag`, so client code will "inherit" those functionality > (`Read`) simple, only with instantiation of `EnumTag` or `StrTag` ? > > Sure, if I comment `instance ... StrTag a` then all work fine, but I need > 2 specialized `Read`s (and `Eq`s too :) > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Fri Dec 1 14:10:57 2017 From: aquagnu at gmail.com (Baa) Date: Fri, 1 Dec 2017 16:10:57 +0200 Subject: [Haskell-beginners] Overlapping instances problem In-Reply-To: References: <20171201135756.5ac0c43d@Pavel> Message-ID: <20171201161057.43bbfbbe@Pavel> Thanks, I got it. So I workarounded the problem with newtypes (all "default" instances are for newtypes, my types are wrapping in those newtypes). === Best regards, Paul > What happens if type 'a' is both an instance EnumTag and StrTag at > the same time? Then which instance does it choose? You may know > that can't happen in your code, but there's no guarantee that someone > using your library or that some import won't bring such a type into > scope. > > Because of this ambiguity, during type checking haskell ignores class > contexts and merely looks at the instance head (Read a), and says hey > there are two instances 'Read a', they are overlapping. > > As to what to do about it, I'm not sure. But I don't think I would be > trying to get different read instances based on whatever typeclasses > happen to be in scope for that type. > > On Fri, Dec 1, 2017 at 6:57 AM, Baa wrote: > > > Hello, List! > > > > I got error: > > > > Duplicate instance declarations: > > instance [overlap ok] EnumTag a => Read a > > -- Defined at /XXX/intero/intero2932Xpa-TEMP.hs:110:27 > > instance [overlap ok] StrTag a => Read a > > -- Defined at /XXX/intero/intero2932Xpa-TEMP.hs:121:27 (intero) > > > > For this code: > > > > class (Show a, Enum a) => EnumTag a where > > anyEnum :: a > > > > instance {-# OVERLAPS #-} EnumTag a => Read a where > > readPrec = RP.lift P.skipSpaces >> expectEnum > > instance {-# OVERLAPS #-} EnumTag a => Eq a where > > a == b | a == anyEnum || b == anyEnum = True > > | otherwise = fromEnum a == fromEnum b > > > > class StrTag a where > > anyStr :: a > > tagPrefix :: a -> String -- ^ should be constant > > toStr :: String -> a > > > > instance {-# OVERLAPS #-} StrTag a => Read a where > > readPrec = parens $ do > > RP.lift P.skipSpaces > > (RP.lift $ expectShown anyStr) <++ RP.lift g > > where g = do > > Just s@(_:_) <- L.stripPrefix tagPrefix <$> expectTag > > return $ toStr s > > > > Why does it happen? `Read a` in 1st instance is valid only when a is > > `EnumTag`, in 2nd one - is valid only when a is `StrTag`. > > > > How can I fix this error and to create "default" instances for > > `EnumTag` and to `StrTag`, so client code will "inherit" those > > functionality (`Read`) simple, only with instantiation of `EnumTag` > > or `StrTag` ? > > > > Sure, if I comment `instance ... StrTag a` then all work fine, but > > I need 2 specialized `Read`s (and `Eq`s too :) > > > > === > > Best regards, Paul > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From aquagnu at gmail.com Mon Dec 4 16:31:02 2017 From: aquagnu at gmail.com (Baa) Date: Mon, 4 Dec 2017 18:31:02 +0200 Subject: [Haskell-beginners] "Shortcut" for f (g x) (g x) Message-ID: <20171204183102.23c72c74@Pavel> Hello, All! Does Haskell have some "short-form" for such call: `f (g x) (g x)`, for example: compare (snd x) (snd x) Looks like combinatory logic or `ap` but not exactly... === Best regards, Paul From exitconsole at gmail.com Mon Dec 4 16:34:45 2017 From: exitconsole at gmail.com (=?UTF-8?B?RMOhbmllbCBBcmF0w7M=?=) Date: Mon, 4 Dec 2017 17:34:45 +0100 Subject: [Haskell-beginners] "Shortcut" for f (g x) (g x) In-Reply-To: <20171204183102.23c72c74@Pavel> References: <20171204183102.23c72c74@Pavel> Message-ID: Hi! I think you're looking for Data.Function.on: http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Function.html#v:on On 04/12/2017, Baa wrote: > Hello, All! > > Does Haskell have some "short-form" for such call: `f (g x) (g x)`, for > example: > > compare (snd x) (snd x) > > Looks like combinatory logic or `ap` but not exactly... > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > From mihai.maruseac at gmail.com Mon Dec 4 16:34:26 2017 From: mihai.maruseac at gmail.com (Mihai Maruseac) Date: Mon, 4 Dec 2017 08:34:26 -0800 Subject: [Haskell-beginners] "Shortcut" for f (g x) (g x) In-Reply-To: <20171204183102.23c72c74@Pavel> References: <20171204183102.23c72c74@Pavel> Message-ID: You can use `liftM2 f g g` For the example you mentioned, there's also compare `on` snd or comparing snd with the proper imports (Data.Ord, Data.Function) On Mon, Dec 4, 2017 at 8:31 AM, Baa wrote: > Hello, All! > > Does Haskell have some "short-form" for such call: `f (g x) (g x)`, for > example: > > compare (snd x) (snd x) > > Looks like combinatory logic or `ap` but not exactly... > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -- Mihai Maruseac (MM) "If you can't solve a problem, then there's an easier problem you can solve: find it." -- George Polya From aquagnu at gmail.com Mon Dec 4 16:51:31 2017 From: aquagnu at gmail.com (Baa) Date: Mon, 4 Dec 2017 18:51:31 +0200 Subject: [Haskell-beginners] "Shortcut" for f (g x) (g x) In-Reply-To: References: <20171204183102.23c72c74@Pavel> Message-ID: <20171204185131.6e27528a@Pavel> Oh, yes! Exactly, thanks to all!! > Hi! > > I think you're looking for Data.Function.on: > http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Function.html#v:on > > On 04/12/2017, Baa wrote: > > Hello, All! > > > > Does Haskell have some "short-form" for such call: `f (g x) (g x)`, > > for example: > > > > compare (snd x) (snd x) > > > > Looks like combinatory logic or `ap` but not exactly... > > > > === > > Best regards, Paul > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From jeffbrown.the at gmail.com Mon Dec 4 17:31:40 2017 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Mon, 4 Dec 2017 12:31:40 -0500 Subject: [Haskell-beginners] "Shortcut" for f (g x) (g x) In-Reply-To: <20171204185131.6e27528a@Pavel> References: <20171204183102.23c72c74@Pavel> <20171204185131.6e27528a@Pavel> Message-ID: This led me to look up the definition of on and discover that punctuation can be used as a variable name for an operator! On Mon, Dec 4, 2017 at 11:51 AM, Baa wrote: > Oh, yes! Exactly, thanks to all!! > > > Hi! > > > > I think you're looking for Data.Function.on: > > http://hackage.haskell.org/package/base-4.10.0.0/docs/ > Data-Function.html#v:on > > > > On 04/12/2017, Baa wrote: > > > Hello, All! > > > > > > Does Haskell have some "short-form" for such call: `f (g x) (g x)`, > > > for example: > > > > > > compare (snd x) (snd x) > > > > > > Looks like combinatory logic or `ap` but not exactly... > > > > > > === > > > Best regards, Paul > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- Jeff Brown | Jeffrey Benjamin Brown Website | Facebook | LinkedIn (spammy, so I often miss messages here) | Github -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrik.mrx at gmail.com Mon Dec 4 19:05:05 2017 From: patrik.mrx at gmail.com (mrx) Date: Mon, 4 Dec 2017 20:05:05 +0100 Subject: [Haskell-beginners] Unpacking tuples In-Reply-To: References: Message-ID: Hi, If I have a function that produce tuples with three members and I want those members as parameters for a function that takes three parameters. How would I unpack that tuple? It seems that curry does the trick for tuples with two members. How do I do this when there are more than two members? Patrik -------------- next part -------------- An HTML attachment was scrubbed... URL: From raabe at froglogic.com Mon Dec 4 19:24:12 2017 From: raabe at froglogic.com (Frerich Raabe) Date: Mon, 04 Dec 2017 20:24:12 +0100 Subject: [Haskell-beginners] Unpacking tuples Message-ID: <91db987b7037b5ecacb0be1b0a81fa7d@froglogic.com> On 2017-12-04 20:05, mrx wrote: > Hi, > > If I have a function that produce tuples with three members and I want those > members as parameters for a function that takes three parameters. > How would I unpack that tuple? > > It seems that curry does the trick for tuples with two members. > > How do I do this when there are more than two members? There are functions like 'curry3' ( http://hackage.haskell.org/package/utility-ht-0.0.14/docs/Data-Tuple-HT.html#v:curry3 ) but I think if you don't need this very often, it might be easiest to just go for let (a,b,c) = f x in g a b c -- Frerich Raabe - raabe at froglogic.com www.froglogic.com - Multi-Platform GUI Testing From patrik.mrx at gmail.com Mon Dec 4 20:40:46 2017 From: patrik.mrx at gmail.com (mrx) Date: Mon, 4 Dec 2017 21:40:46 +0100 Subject: [Haskell-beginners] Unpacking tuples In-Reply-To: <91db987b7037b5ecacb0be1b0a81fa7d@froglogic.com> References: <91db987b7037b5ecacb0be1b0a81fa7d@froglogic.com> Message-ID: Den 4 dec 2017 20:25 skrev "Frerich Raabe" : On 2017-12-04 20:05, mrx wrote: > Hi, > > If I have a function that produce tuples with three members and I want > those members as parameters for a function that takes three parameters. > How would I unpack that tuple? > > It seems that curry does the trick for tuples with two members. > > How do I do this when there are more than two members? > There are functions like 'curry3' ( http://hackage.haskell.org/pac kage/utility-ht-0.0.14/docs/Data-Tuple-HT.html#v:curry3 ) but I think if you don't need this very often, it might be easiest to just go for let (a,b,c) = f x in g a b c Ok, so in general I would have to write the unpacking myself. Correct? // Patrik -------------- next part -------------- An HTML attachment was scrubbed... URL: From quentin.liu.0415 at gmail.com Thu Dec 7 06:43:22 2017 From: quentin.liu.0415 at gmail.com (Quentin Liu) Date: Thu, 7 Dec 2017 01:43:22 -0500 Subject: [Haskell-beginners] Stack could not find libHStransformers Message-ID: Hi, I was trying to use Parsec and imported Text.ParserCombinators.Parsec. I could call “stack ghc” to compile the file, but when I loaded the file into ghci and called any function, ghci would report errors > can't load .so/.DLL for: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib (dlopen(/Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib, 5): Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0.2/transformers-0.5.2.0/libHStransformers-0.5.2.0-ghc8.0.2.dylib >   Referenced from: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib >   Reason: image not found) > I tried to install transformers by calling `stack install transformers` but the problem still persisted. Is it because the version of transformers in my repo is different from the one referenced by `mtl` package? How should I fix it? Regards, Qingbo Liu -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Thu Dec 7 06:54:45 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 7 Dec 2017 08:54:45 +0200 Subject: [Haskell-beginners] Stack could not find libHStransformers In-Reply-To: References: Message-ID: What version of Stack are you using (stack --version), and how did you install Stack and GHC? It looks like you're using a system-wide GHC installation, which (for reasons like this) we by default no longer use by default in recent Stack releases. Upgrading to the latest Stack (via `stack upgrade` or following the instructions at [1]) will probably solve the problem. [1] https://haskell-lang.org/get-started/osx On Thu, Dec 7, 2017 at 8:43 AM, Quentin Liu wrote: > Hi, > > I was trying to use Parsec and imported Text.ParserCombinators.Parsec. I > could call “stack ghc” to compile the file, but when I loaded the file into > ghci and called any function, ghci would report errors > > can't load .so/.DLL for: /Users/HereWegoR/.stack/ > snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0. > 2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib > (dlopen(/Users/HereWegoR/.stack/snapshots/x86_64-osx/ > lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1- > BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib, 5): Library not loaded: > /usr/local/opt/ghc/lib/ghc-8.0.2/transformers-0.5.2.0/ > libHStransformers-0.5.2.0-ghc8.0.2.dylib > Referenced from: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/ > 8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1- > BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib > Reason: image not found) > > > I tried to install transformers by calling `stack install transformers` > but the problem still persisted. Is it because the version of transformers > in my repo is different from the one referenced by `mtl` package? How > should I fix it? > > Regards, > Qingbo Liu > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Thu Dec 7 11:41:08 2017 From: aquagnu at gmail.com (Baa) Date: Thu, 7 Dec 2017 13:41:08 +0200 Subject: [Haskell-beginners] Little question about "forall" Message-ID: <20171207134108.1ae548b8@Pavel> Hello everyone! Suppose I have: class C a where someA :: a f :: C a => a -> Int f a = let x = someA :: a in -- BUG!! 0 BUG as I understand I due to `:: a` - this is another `a`, not the same as in `f` singature. But seems that it's the same `a` if `f` is the "method" of some instance. And such bug does not happen if I return it, so my question is how to create such `x` of type `a` in the body of the `f`? How to use `a` anywhere in the body of `f`? Is it possible? I found a way if I change signature to `forall a. C a => a -> Int`. But there are another questions in the case: - as I know all such params are under "forall" in Haskell by-default. Seems it's not true? - in method body seems they are under "forall" but in simple functions - not? - i'm not sure what exactly does this "forall", IMHO it unbounds early bound type's variables (parameters) by typechecker, but how `a` can be bound in the just begining of signature (where it occurs first time) ?! As for me, looks that w/o "forall" all `a`, `b`, `c`, etc in the body of simple functions always are different types. But w/ "forall" Haskell typechecker makes something like (on type-level): let a = ANY-TYPE in ... here `a` can occur and will be bound to ANY-TYPE Where am I right and where am I wrong? :) === Best regards, Paul From toad3k at gmail.com Thu Dec 7 14:05:04 2017 From: toad3k at gmail.com (David McBride) Date: Thu, 7 Dec 2017 09:05:04 -0500 Subject: [Haskell-beginners] Little question about "forall" In-Reply-To: <20171207134108.1ae548b8@Pavel> References: <20171207134108.1ae548b8@Pavel> Message-ID: As to your original code, the only actual bug is that someA :: a is wrong. The actual type of someA is someA :: C a => a, so you could have written class C a where someA :: a f :: C a => a -> Int f a = let x :: C a => a x = someA -- absolutely works in 0 But remember that in x, 'a' is not the same as the 'a' in f, so you might as well have written this f :: C a => a -> Int f a = let x :: C b => b x = someA -- also works in 0 This is how it works. When you write f :: C a => a -> () f = let x = someA -- without ':: a' () The problem is that by not giving an explicit type to x, ghc infers a type and for all intents and purposes it is as though you wrote f :: C a => a -> () f = let x :: C a1 => a1 x = someA -- also if you had written x = some :: a, it just means you effectively wrote -- let x :: C a1 => a1 -- x = someA :: a -- but 'a1' is not equivalent to 'a', so it errors. () And so it says hey wait, a and a1 could be different types. That is why you often see ghc referring to 'a1' or 'a0' in error messages, because when it infers a type it has to give a name to it in order to report on it. What ScopedTypeVariables does is allow you to specify that for the entire scope of this forall, 'a' in any type signature always refers to the same type. f :: forall a. C a => a -> () f = undefined where some :: a -- this is guaranteed to be the a from above. some = undefined somethingelse :: forall a. a -- this is a different a somethingelse = undefined some :: a -- this toplevel a is of course also different. some = undefined So you could just go {-# LANGUAGE ScopedTypeVariables #-} f :: forall a. C a => a -> Int f a = let x :: a -- now the a is the same a as above, so the constraint C a is understood. x = someA in 0 I really love the ScopedTypeVariables extension, and so do a lot of other people. I honestly think it should be on by default because the pitfalls of not having it on are a lot worse than the pitfalls of having it on. The only pitfall I know of to having it on is that if you have a function with tons of lets and / or wheres, you might not notice you had used the type variable 'a' in two different incompatible places. Hopefully all this makes sense. On Thu, Dec 7, 2017 at 6:41 AM, Baa wrote: > Hello everyone! > > Suppose I have: > > class C a where > someA :: a > > f :: C a => a -> Int > f a = > let x = someA :: a in -- BUG!! > 0 > > BUG as I understand I due to `:: a` - this is another `a`, not the same as > in `f` singature. But seems that it's the same `a` if `f` is the "method" > of some instance. And such bug does not happen if I return it, so my > question > is how to create such `x` of type `a` in the body of the `f`? How to use > `a` anywhere in the body of `f`? Is it possible? > > I found a way if I change signature to `forall a. C a => a -> Int`. But > there > are another questions in the case: > > - as I know all such params are under "forall" in Haskell by-default. > Seems > it's not true? > - in method body seems they are under "forall" but in simple functions - > not? > - i'm not sure what exactly does this "forall", IMHO it unbounds early > bound > type's variables (parameters) by typechecker, but how `a` can be bound > in the > just begining of signature (where it occurs first time) ?! > > As for me, looks that w/o "forall" all `a`, `b`, `c`, etc in the body of > simple functions always are different types. But w/ "forall" Haskell > typechecker > makes something like (on type-level): > > let a = ANY-TYPE > in > ... here `a` can occur and will be bound to ANY-TYPE > > Where am I right and where am I wrong? :) > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Thu Dec 7 15:31:54 2017 From: aquagnu at gmail.com (Baa) Date: Thu, 7 Dec 2017 17:31:54 +0200 Subject: [Haskell-beginners] Little question about "forall" In-Reply-To: References: <20171207134108.1ae548b8@Pavel> Message-ID: <20171207173154.5cfc935c@Pavel> Hello, David! > But remember that in x, 'a' is not the same as the 'a' in f, so you Exactly, and I often hit errors like "Can't match rigid type 'M a' with rigid type 'M a1'"! So, the question comes down to "forall" and "ScopedTypeVariables". Did I understand you correctly: this extension expands type-variable scope to whole function body. But what sort of type vairables? Only under "forall ...", right ? And another question: type-variables under "forall" - they are rigid? Or free? I can't understand the terminology. I thought early that they are called "rigid", but in documentation of "ScopedTypeVariables" extension they are called "free". IMHO symbol ∀ means "unbound", so "free". But I often hit errors when GHC says something about rigid, so I'm not sure - what is rigid? Bound? And last: why I need "forall a." in beginning of signature while Haskell assumes "forall" for all type variables by default? Or I'm not right here... > As to your original code, the only actual bug is that someA :: a is > wrong. The actual type of someA is someA :: C a => a, so you could > have written > > class C a where > someA :: a > > f :: C a => a -> Int > f a = > let x :: C a => a > x = someA -- absolutely works > in 0 > > > But remember that in x, 'a' is not the same as the 'a' in f, so you > might as well have written this > > f :: C a => a -> Int > f a = > let x :: C b => b > x = someA -- also works > in 0 > > This is how it works. When you write > > f :: C a => a -> () > f = > let x = someA -- without ':: a' > () > > The problem is that by not giving an explicit type to x, ghc infers a > type and for all intents and purposes it is as though you wrote > > f :: C a => a -> () > f = > let x :: C a1 => a1 > x = someA > -- also if you had written x = some :: a, it just means you > effectively wrote > -- let x :: C a1 => a1 > -- x = someA :: a > -- but 'a1' is not equivalent to 'a', so it errors. > () > > And so it says hey wait, a and a1 could be different types. That is > why you often see ghc referring to 'a1' or 'a0' in error messages, > because when it infers a type it has to give a name to it in order to > report on it. > > What ScopedTypeVariables does is allow you to specify that for the > entire scope of this forall, 'a' in any type signature always refers > to the same type. > > f :: forall a. C a => a -> () > f = undefined > where > some :: a -- this is guaranteed to be the a from above. > some = undefined > > somethingelse :: forall a. a -- this is a different a > somethingelse = undefined > > some :: a -- this toplevel a is of course also different. > some = undefined > > So you could just go > {-# LANGUAGE ScopedTypeVariables #-} > > f :: forall a. C a => a -> Int > f a = > let > x :: a -- now the a is the same a as above, so the constraint C > a is understood. > x = someA > in 0 > > I really love the ScopedTypeVariables extension, and so do a lot of > other people. I honestly think it should be on by default because > the pitfalls of not having it on are a lot worse than the pitfalls of > having it on. The only pitfall I know of to having it on is that if > you have a function with tons of lets and / or wheres, you might not > notice you had used the type variable 'a' in two different > incompatible places. > > Hopefully all this makes sense. > > > > On Thu, Dec 7, 2017 at 6:41 AM, Baa wrote: > > > Hello everyone! > > > > Suppose I have: > > > > class C a where > > someA :: a > > > > f :: C a => a -> Int > > f a = > > let x = someA :: a in -- BUG!! > > 0 > > > > BUG as I understand I due to `:: a` - this is another `a`, not the > > same as in `f` singature. But seems that it's the same `a` if `f` > > is the "method" of some instance. And such bug does not happen if I > > return it, so my question > > is how to create such `x` of type `a` in the body of the `f`? How > > to use `a` anywhere in the body of `f`? Is it possible? > > > > I found a way if I change signature to `forall a. C a => a -> Int`. > > But there > > are another questions in the case: > > > > - as I know all such params are under "forall" in Haskell > > by-default. Seems > > it's not true? > > - in method body seems they are under "forall" but in simple > > functions - not? > > - i'm not sure what exactly does this "forall", IMHO it unbounds > > early bound > > type's variables (parameters) by typechecker, but how `a` can be > > bound in the > > just begining of signature (where it occurs first time) ?! > > > > As for me, looks that w/o "forall" all `a`, `b`, `c`, etc in the > > body of simple functions always are different types. But w/ > > "forall" Haskell typechecker > > makes something like (on type-level): > > > > let a = ANY-TYPE > > in > > ... here `a` can occur and will be bound to ANY-TYPE > > > > Where am I right and where am I wrong? :) > > > > === > > Best regards, Paul > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From quentin.liu.0415 at gmail.com Thu Dec 7 15:42:08 2017 From: quentin.liu.0415 at gmail.com (Quentin Liu) Date: Thu, 7 Dec 2017 10:42:08 -0500 Subject: [Haskell-beginners] Stack could not find libHStransformers In-Reply-To: References: Message-ID: <02ba63c5-632b-4175-b496-086b6c20d8cc@Spark> I am using ghc download and managed by stack. My stack is of the latest version, which is 1.6.1. Regards, Qingbo Liu On Dec 7, 2017, 01:56 -0500, Michael Snoyman , wrote: > What version of Stack are you using (stack --version), and how did you install Stack and GHC? > > It looks like you're using a system-wide GHC installation, which (for reasons like this) we by default no longer use by default in recent Stack releases. > > Upgrading to the latest Stack (via `stack upgrade` or following the instructions at [1]) will probably solve the problem. > > [1] https://haskell-lang.org/get-started/osx > > > On Thu, Dec 7, 2017 at 8:43 AM, Quentin Liu wrote: > > > Hi, > > > > > > I was trying to use Parsec and imported Text.ParserCombinators.Parsec. I could call “stack ghc” to compile the file, but when I loaded the file into ghci and called any function, ghci would report errors > > > > can't load .so/.DLL for: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib (dlopen(/Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib, 5): Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0.2/transformers-0.5.2.0/libHStransformers-0.5.2.0-ghc8.0.2.dylib > > > >   Referenced from: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib > > > >   Reason: image not found) > > > > > > > > > > I tried to install transformers by calling `stack install transformers` but the problem still persisted. Is it because the version of transformers in my repo is different from the one referenced by `mtl` package? How should I fix it? > > > > > > Regards, > > > Qingbo Liu > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Thu Dec 7 15:48:39 2017 From: toad3k at gmail.com (David McBride) Date: Thu, 7 Dec 2017 10:48:39 -0500 Subject: [Haskell-beginners] Little question about "forall" In-Reply-To: <20171207173154.5cfc935c@Pavel> References: <20171207134108.1ae548b8@Pavel> <20171207173154.5cfc935c@Pavel> Message-ID: Rigid just means the compiler knows the type without having to infer it. And if the type is inferred to be different than what you said it should be, you get an error that says 's' is a rigid type variable bound by ... presumably the type signature. I'm not sure what free means. My best guess is that a local variable is free if it is not referred to in the type signature of the encompassing (? surrounding?) scope. forall a. is just what what ScopedTypeVariables uses to ensure that local variables in the function with the same type variables are no longer free, and that they must adhere to the type signature of the encompassing scope. My terminology is terrible, and I've probably made a mistake, but hopefully someone will correct me. On Thu, Dec 7, 2017 at 10:31 AM, Baa wrote: > Hello, David! > > > But remember that in x, 'a' is not the same as the 'a' in f, so you > > Exactly, and I often hit errors like "Can't match rigid type 'M a' with > rigid type 'M a1'"! So, the question comes down to "forall" and > "ScopedTypeVariables". Did I understand you correctly: > > this extension expands type-variable scope to whole function body. But > what sort of type vairables? Only under "forall ...", right ? > > And another question: type-variables under "forall" - they are rigid? > Or free? I can't understand the terminology. I thought early that they > are called "rigid", but in documentation of "ScopedTypeVariables" > extension they are called "free". IMHO symbol ∀ means "unbound", so > "free". But I often hit errors when GHC says something about rigid, so > I'm not sure - what is rigid? Bound? > > And last: why I need "forall a." in beginning of signature while > Haskell assumes "forall" for all type variables by default? Or I'm not > right here... > > > > As to your original code, the only actual bug is that someA :: a is > > wrong. The actual type of someA is someA :: C a => a, so you could > > have written > > > > class C a where > > someA :: a > > > > f :: C a => a -> Int > > f a = > > let x :: C a => a > > x = someA -- absolutely works > > in 0 > > > > > > But remember that in x, 'a' is not the same as the 'a' in f, so you > > might as well have written this > > > > f :: C a => a -> Int > > f a = > > let x :: C b => b > > x = someA -- also works > > in 0 > > > > This is how it works. When you write > > > > f :: C a => a -> () > > f = > > let x = someA -- without ':: a' > > () > > > > The problem is that by not giving an explicit type to x, ghc infers a > > type and for all intents and purposes it is as though you wrote > > > > f :: C a => a -> () > > f = > > let x :: C a1 => a1 > > x = someA > > -- also if you had written x = some :: a, it just means you > > effectively wrote > > -- let x :: C a1 => a1 > > -- x = someA :: a > > -- but 'a1' is not equivalent to 'a', so it errors. > > () > > > > And so it says hey wait, a and a1 could be different types. That is > > why you often see ghc referring to 'a1' or 'a0' in error messages, > > because when it infers a type it has to give a name to it in order to > > report on it. > > > > What ScopedTypeVariables does is allow you to specify that for the > > entire scope of this forall, 'a' in any type signature always refers > > to the same type. > > > > f :: forall a. C a => a -> () > > f = undefined > > where > > some :: a -- this is guaranteed to be the a from above. > > some = undefined > > > > somethingelse :: forall a. a -- this is a different a > > somethingelse = undefined > > > > some :: a -- this toplevel a is of course also different. > > some = undefined > > > > So you could just go > > {-# LANGUAGE ScopedTypeVariables #-} > > > > f :: forall a. C a => a -> Int > > f a = > > let > > x :: a -- now the a is the same a as above, so the constraint C > > a is understood. > > x = someA > > in 0 > > > > I really love the ScopedTypeVariables extension, and so do a lot of > > other people. I honestly think it should be on by default because > > the pitfalls of not having it on are a lot worse than the pitfalls of > > having it on. The only pitfall I know of to having it on is that if > > you have a function with tons of lets and / or wheres, you might not > > notice you had used the type variable 'a' in two different > > incompatible places. > > > > Hopefully all this makes sense. > > > > > > > > On Thu, Dec 7, 2017 at 6:41 AM, Baa wrote: > > > > > Hello everyone! > > > > > > Suppose I have: > > > > > > class C a where > > > someA :: a > > > > > > f :: C a => a -> Int > > > f a = > > > let x = someA :: a in -- BUG!! > > > 0 > > > > > > BUG as I understand I due to `:: a` - this is another `a`, not the > > > same as in `f` singature. But seems that it's the same `a` if `f` > > > is the "method" of some instance. And such bug does not happen if I > > > return it, so my question > > > is how to create such `x` of type `a` in the body of the `f`? How > > > to use `a` anywhere in the body of `f`? Is it possible? > > > > > > I found a way if I change signature to `forall a. C a => a -> Int`. > > > But there > > > are another questions in the case: > > > > > > - as I know all such params are under "forall" in Haskell > > > by-default. Seems > > > it's not true? > > > - in method body seems they are under "forall" but in simple > > > functions - not? > > > - i'm not sure what exactly does this "forall", IMHO it unbounds > > > early bound > > > type's variables (parameters) by typechecker, but how `a` can be > > > bound in the > > > just begining of signature (where it occurs first time) ?! > > > > > > As for me, looks that w/o "forall" all `a`, `b`, `c`, etc in the > > > body of simple functions always are different types. But w/ > > > "forall" Haskell typechecker > > > makes something like (on type-level): > > > > > > let a = ANY-TYPE > > > in > > > ... here `a` can occur and will be bound to ANY-TYPE > > > > > > Where am I right and where am I wrong? :) > > > > > > === > > > Best regards, Paul > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Thu Dec 7 16:12:48 2017 From: aquagnu at gmail.com (Baa) Date: Thu, 7 Dec 2017 18:12:48 +0200 Subject: [Haskell-beginners] Little question about "forall" In-Reply-To: References: <20171207134108.1ae548b8@Pavel> <20171207173154.5cfc935c@Pavel> Message-ID: <20171207181248.5c39c851@Pavel> > forall a. is just what what ScopedTypeVariables uses to ensure that > local variables in the function with the same type variables are no > longer free, and that they must adhere to the type signature of the > encompassing scope. Hmm, OK, so the extension analizes code/AST and finds a types which are under "forall" and links them (to be exactly the same type at whole scope). Only open question here is: seems that "forall-by-default" is not absilutely true :) > My terminology is terrible, and I've probably made a mistake, but > hopefully someone will correct me. May be I'm not correctly here but Haskell-terminology IMHO is terrible at whole: I found in mail-lists posts about it (that terms are unsuccessful, confusing). As for me, after some Prolog experience I understand what is unification, bound var and not-bound var intuitively - it's clean terminology. So, GHC type-checker for me is some kind of Prolog and if result is True (with all constaints and types relations) then type-checking is passed. But terminology is different and confuse me and I suppose other newbies too: I found already "rigid", "free", "skolem", "bound", etc :-) David, thanks a lot!! === Best regards, Paul > > On Thu, Dec 7, 2017 at 10:31 AM, Baa wrote: > > > Hello, David! > > > > > But remember that in x, 'a' is not the same as the 'a' in f, so > > > you > > > > Exactly, and I often hit errors like "Can't match rigid type 'M a' > > with rigid type 'M a1'"! So, the question comes down to "forall" and > > "ScopedTypeVariables". Did I understand you correctly: > > > > this extension expands type-variable scope to whole function body. > > But what sort of type vairables? Only under "forall ...", right ? > > > > And another question: type-variables under "forall" - they are > > rigid? Or free? I can't understand the terminology. I thought early > > that they are called "rigid", but in documentation of > > "ScopedTypeVariables" extension they are called "free". IMHO symbol > > ∀ means "unbound", so "free". But I often hit errors when GHC says > > something about rigid, so I'm not sure - what is rigid? Bound? > > > > And last: why I need "forall a." in beginning of signature while > > Haskell assumes "forall" for all type variables by default? Or I'm > > not right here... > > > > > > > As to your original code, the only actual bug is that someA :: a > > > is wrong. The actual type of someA is someA :: C a => a, so you > > > could have written > > > > > > class C a where > > > someA :: a > > > > > > f :: C a => a -> Int > > > f a = > > > let x :: C a => a > > > x = someA -- absolutely works > > > in 0 > > > > > > > > > But remember that in x, 'a' is not the same as the 'a' in f, so > > > you might as well have written this > > > > > > f :: C a => a -> Int > > > f a = > > > let x :: C b => b > > > x = someA -- also works > > > in 0 > > > > > > This is how it works. When you write > > > > > > f :: C a => a -> () > > > f = > > > let x = someA -- without ':: a' > > > () > > > > > > The problem is that by not giving an explicit type to x, ghc > > > infers a type and for all intents and purposes it is as though > > > you wrote > > > > > > f :: C a => a -> () > > > f = > > > let x :: C a1 => a1 > > > x = someA > > > -- also if you had written x = some :: a, it just means you > > > effectively wrote > > > -- let x :: C a1 => a1 > > > -- x = someA :: a > > > -- but 'a1' is not equivalent to 'a', so it errors. > > > () > > > > > > And so it says hey wait, a and a1 could be different types. That > > > is why you often see ghc referring to 'a1' or 'a0' in error > > > messages, because when it infers a type it has to give a name to > > > it in order to report on it. > > > > > > What ScopedTypeVariables does is allow you to specify that for the > > > entire scope of this forall, 'a' in any type signature always > > > refers to the same type. > > > > > > f :: forall a. C a => a -> () > > > f = undefined > > > where > > > some :: a -- this is guaranteed to be the a from above. > > > some = undefined > > > > > > somethingelse :: forall a. a -- this is a different a > > > somethingelse = undefined > > > > > > some :: a -- this toplevel a is of course also different. > > > some = undefined > > > > > > So you could just go > > > {-# LANGUAGE ScopedTypeVariables #-} > > > > > > f :: forall a. C a => a -> Int > > > f a = > > > let > > > x :: a -- now the a is the same a as above, so the > > > constraint C a is understood. > > > x = someA > > > in 0 > > > > > > I really love the ScopedTypeVariables extension, and so do a lot > > > of other people. I honestly think it should be on by default > > > because the pitfalls of not having it on are a lot worse than the > > > pitfalls of having it on. The only pitfall I know of to having > > > it on is that if you have a function with tons of lets and / or > > > wheres, you might not notice you had used the type variable 'a' > > > in two different incompatible places. > > > > > > Hopefully all this makes sense. > > > > > > > > > > > > On Thu, Dec 7, 2017 at 6:41 AM, Baa wrote: > > > > > > > Hello everyone! > > > > > > > > Suppose I have: > > > > > > > > class C a where > > > > someA :: a > > > > > > > > f :: C a => a -> Int > > > > f a = > > > > let x = someA :: a in -- BUG!! > > > > 0 > > > > > > > > BUG as I understand I due to `:: a` - this is another `a`, not > > > > the same as in `f` singature. But seems that it's the same `a` > > > > if `f` is the "method" of some instance. And such bug does not > > > > happen if I return it, so my question > > > > is how to create such `x` of type `a` in the body of the `f`? > > > > How to use `a` anywhere in the body of `f`? Is it possible? > > > > > > > > I found a way if I change signature to `forall a. C a => a -> > > > > Int`. But there > > > > are another questions in the case: > > > > > > > > - as I know all such params are under "forall" in Haskell > > > > by-default. Seems > > > > it's not true? > > > > - in method body seems they are under "forall" but in simple > > > > functions - not? > > > > - i'm not sure what exactly does this "forall", IMHO it > > > > unbounds early bound > > > > type's variables (parameters) by typechecker, but how `a` > > > > can be bound in the > > > > just begining of signature (where it occurs first time) ?! > > > > > > > > As for me, looks that w/o "forall" all `a`, `b`, `c`, etc in the > > > > body of simple functions always are different types. But w/ > > > > "forall" Haskell typechecker > > > > makes something like (on type-level): > > > > > > > > let a = ANY-TYPE > > > > in > > > > ... here `a` can occur and will be bound to ANY-TYPE > > > > > > > > Where am I right and where am I wrong? :) > > > > > > > > === > > > > Best regards, Paul > > > > _______________________________________________ > > > > Beginners mailing list > > > > Beginners at haskell.org > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From michael at snoyman.com Thu Dec 7 16:31:12 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 7 Dec 2017 18:31:12 +0200 Subject: [Haskell-beginners] Stack could not find libHStransformers In-Reply-To: <02ba63c5-632b-4175-b496-086b6c20d8cc@Spark> References: <02ba63c5-632b-4175-b496-086b6c20d8cc@Spark> Message-ID: Some ideas: * What does this output: `which ghc ; stack exec which ghc` * What does your stack.yaml look like? * Do you have a .ghci or other kinds of local configuration file? On Thu, Dec 7, 2017 at 5:42 PM, Quentin Liu wrote: > I am using ghc download and managed by stack. My stack is of the latest > version, which is 1.6.1. > > Regards, > Qingbo Liu > > On Dec 7, 2017, 01:56 -0500, Michael Snoyman , wrote: > > What version of Stack are you using (stack --version), and how did you > install Stack and GHC? > > It looks like you're using a system-wide GHC installation, which (for > reasons like this) we by default no longer use by default in recent Stack > releases. > > Upgrading to the latest Stack (via `stack upgrade` or following the > instructions at [1]) will probably solve the problem. > > [1] https://haskell-lang.org/get-started/osx > > On Thu, Dec 7, 2017 at 8:43 AM, Quentin Liu > wrote: > >> Hi, >> >> I was trying to use Parsec and imported Text.ParserCombinators.Parsec. I >> could call “stack ghc” to compile the file, but when I loaded the file into >> ghci and called any function, ghci would report errors >> >> can't load .so/.DLL for: /Users/HereWegoR/.stack/snapsh >> ots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/ >> libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib >> (dlopen(/Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8. >> 8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib, >> 5): Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0 >> .2/transformers-0.5.2.0/libHStransformers-0.5.2.0-ghc8.0.2.dylib >> Referenced from: /Users/HereWegoR/.stack/snapsh >> ots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/ >> libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib >> Reason: image not found) >> >> >> I tried to install transformers by calling `stack install transformers` >> but the problem still persisted. Is it because the version of transformers >> in my repo is different from the one referenced by `mtl` package? How >> should I fix it? >> >> Regards, >> Qingbo Liu >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From quentin.liu.0415 at gmail.com Thu Dec 7 17:05:45 2017 From: quentin.liu.0415 at gmail.com (Quentin Liu) Date: Thu, 7 Dec 2017 12:05:45 -0500 Subject: [Haskell-beginners] Stack could not find libHStransformers In-Reply-To: References: <02ba63c5-632b-4175-b496-086b6c20d8cc@Spark> Message-ID: <384fa199-2adb-4741-9212-833a282bd2df@Spark> > What does this output: `which ghc ; stack exec which ghc` `which ghc` gives "ghc not found”, while `stack exec which ghc` gives "/Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc”. > What does your stack.yaml look like? For this file I don’t have any stack.yaml. I just wrote the file and tried to load it into ghci. > Do you have a .ghci or other kinds of local configuration file? As far as I can tell, no. Regards, Qingbo Liu On Dec 7, 2017, 11:33 -0500, Michael Snoyman , wrote: > Some ideas: > > * What does this output: `which ghc ; stack exec which ghc` > * What does your stack.yaml look like? > * Do you have a .ghci or other kinds of local configuration file? > > > On Thu, Dec 7, 2017 at 5:42 PM, Quentin Liu wrote: > > > I am using ghc download and managed by stack. My stack is of the latest version, which is 1.6.1. > > > > > > Regards, > > > Qingbo Liu > > > > > > On Dec 7, 2017, 01:56 -0500, Michael Snoyman , wrote: > > > > What version of Stack are you using (stack --version), and how did you install Stack and GHC? > > > > > > > > It looks like you're using a system-wide GHC installation, which (for reasons like this) we by default no longer use by default in recent Stack releases. > > > > > > > > Upgrading to the latest Stack (via `stack upgrade` or following the instructions at [1]) will probably solve the problem. > > > > > > > > [1] https://haskell-lang.org/get-started/osx > > > > > > > > > On Thu, Dec 7, 2017 at 8:43 AM, Quentin Liu wrote: > > > > > > Hi, > > > > > > > > > > > > I was trying to use Parsec and imported Text.ParserCombinators.Parsec. I could call “stack ghc” to compile the file, but when I loaded the file into ghci and called any function, ghci would report errors > > > > > > > can't load .so/.DLL for: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib (dlopen(/Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib, 5): Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0.2/transformers-0.5.2.0/libHStransformers-0.5.2.0-ghc8.0.2.dylib > > > > > > >   Referenced from: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib > > > > > > >   Reason: image not found) > > > > > > > > > > > > > > > > > > > I tried to install transformers by calling `stack install transformers` but the problem still persisted. Is it because the version of transformers in my repo is different from the one referenced by `mtl` package? How should I fix it? > > > > > > > > > > > > Regards, > > > > > > Qingbo Liu > > > > > > > > > > > > _______________________________________________ > > > > > > Beginners mailing list > > > > > > Beginners at haskell.org > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > > > _______________________________________________ > > > > Beginners mailing list > > > > Beginners at haskell.org > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Thu Dec 7 17:28:54 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 7 Dec 2017 19:28:54 +0200 Subject: [Haskell-beginners] Stack could not find libHStransformers In-Reply-To: <384fa199-2adb-4741-9212-833a282bd2df@Spark> References: <02ba63c5-632b-4175-b496-086b6c20d8cc@Spark> <384fa199-2adb-4741-9212-833a282bd2df@Spark> Message-ID: I'm not sure how it happened, but it looks like you ended up with some files in ~/.stack which are linked against a system-wide GHC. In particular: Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0.2/transformers-0.5.2.0/ libHStransformers-0.5.2.0-ghc8.0.2.dylib The easiest way to fix this is to just wipe out your ~/.stack directory, which will result in having to do some recompiles, but otherwise should be harmless. On Thu, Dec 7, 2017 at 7:05 PM, Quentin Liu wrote: > What does this output: `which ghc ; stack exec which ghc` > > `which ghc` gives "ghc not found”, while `stack exec which ghc` gives > "/Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc”. > > What does your stack.yaml look like? > > For this file I don’t have any stack.yaml. I just wrote the file and tried > to load it into ghci. > > Do you have a .ghci or other kinds of local configuration file? > > As far as I can tell, no. > > Regards, > Qingbo Liu > > On Dec 7, 2017, 11:33 -0500, Michael Snoyman , wrote: > > Some ideas: > > * What does this output: `which ghc ; stack exec which ghc` > * What does your stack.yaml look like? > * Do you have a .ghci or other kinds of local configuration file? > > On Thu, Dec 7, 2017 at 5:42 PM, Quentin Liu > wrote: > >> I am using ghc download and managed by stack. My stack is of the latest >> version, which is 1.6.1. >> >> Regards, >> Qingbo Liu >> >> On Dec 7, 2017, 01:56 -0500, Michael Snoyman , >> wrote: >> >> What version of Stack are you using (stack --version), and how did you >> install Stack and GHC? >> >> It looks like you're using a system-wide GHC installation, which (for >> reasons like this) we by default no longer use by default in recent Stack >> releases. >> >> Upgrading to the latest Stack (via `stack upgrade` or following the >> instructions at [1]) will probably solve the problem. >> >> [1] https://haskell-lang.org/get-started/osx >> >> On Thu, Dec 7, 2017 at 8:43 AM, Quentin Liu >> wrote: >> >>> Hi, >>> >>> I was trying to use Parsec and imported Text.ParserCombinators.Parsec. I >>> could call “stack ghc” to compile the file, but when I loaded the file into >>> ghci and called any function, ghci would report errors >>> >>> can't load .so/.DLL for: /Users/HereWegoR/.stack/snapsh >>> ots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSm >>> tl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib >>> (dlopen(/Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8 >>> /8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib, >>> 5): Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0 >>> .2/transformers-0.5.2.0/libHStransformers-0.5.2.0-ghc8.0.2.dylib >>> Referenced from: /Users/HereWegoR/.stack/snapsh >>> ots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSm >>> tl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib >>> Reason: image not found) >>> >>> >>> I tried to install transformers by calling `stack install transformers` >>> but the problem still persisted. Is it because the version of transformers >>> in my repo is different from the one referenced by `mtl` package? How >>> should I fix it? >>> >>> Regards, >>> Qingbo Liu >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >>> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From quentin.liu.0415 at gmail.com Thu Dec 7 19:50:19 2017 From: quentin.liu.0415 at gmail.com (Quentin Liu) Date: Thu, 7 Dec 2017 14:50:19 -0500 Subject: [Haskell-beginners] Stack could not find libHStransformers In-Reply-To: References: <02ba63c5-632b-4175-b496-086b6c20d8cc@Spark> <384fa199-2adb-4741-9212-833a282bd2df@Spark> Message-ID: <0ad4de58-494d-474d-8871-d5ebfb12a246@Spark> Thanks! It really helps. Regards, Qingbo Liu On Dec 7, 2017, 12:31 -0500, Michael Snoyman , wrote: > I'm not sure how it happened, but it looks like you ended up with some files in ~/.stack which are linked against a system-wide GHC. In particular: > > Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0.2/transformers-0.5.2.0/libHStransformers-0.5.2.0-ghc8.0.2.dylib > > The easiest way to fix this is to just wipe out your ~/.stack directory, which will result in having to do some recompiles, but otherwise should be harmless. > > > On Thu, Dec 7, 2017 at 7:05 PM, Quentin Liu wrote: > > > > What does this output: `which ghc ; stack exec which ghc` > > > `which ghc` gives "ghc not found”, while `stack exec which ghc` gives "/Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc”. > > > > > > > What does your stack.yaml look like? > > > For this file I don’t have any stack.yaml. I just wrote the file and tried to load it into ghci. > > > > > > > Do you have a .ghci or other kinds of local configuration file? > > > As far as I can tell, no. > > > > > > Regards, > > > Qingbo Liu > > > > > > On Dec 7, 2017, 11:33 -0500, Michael Snoyman , wrote: > > > > Some ideas: > > > > > > > > * What does this output: `which ghc ; stack exec which ghc` > > > > * What does your stack.yaml look like? > > > > * Do you have a .ghci or other kinds of local configuration file? > > > > > > > > > On Thu, Dec 7, 2017 at 5:42 PM, Quentin Liu wrote: > > > > > > I am using ghc download and managed by stack. My stack is of the latest version, which is 1.6.1. > > > > > > > > > > > > Regards, > > > > > > Qingbo Liu > > > > > > > > > > > > On Dec 7, 2017, 01:56 -0500, Michael Snoyman , wrote: > > > > > > > What version of Stack are you using (stack --version), and how did you install Stack and GHC? > > > > > > > > > > > > > > It looks like you're using a system-wide GHC installation, which (for reasons like this) we by default no longer use by default in recent Stack releases. > > > > > > > > > > > > > > Upgrading to the latest Stack (via `stack upgrade` or following the instructions at [1]) will probably solve the problem. > > > > > > > > > > > > > > [1] https://haskell-lang.org/get-started/osx > > > > > > > > > > > > > > > On Thu, Dec 7, 2017 at 8:43 AM, Quentin Liu wrote: > > > > > > > > > Hi, > > > > > > > > > > > > > > > > > > I was trying to use Parsec and imported Text.ParserCombinators.Parsec. I could call “stack ghc” to compile the file, but when I loaded the file into ghci and called any function, ghci would report errors > > > > > > > > > > can't load .so/.DLL for: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib (dlopen(/Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib, 5): Library not loaded: /usr/local/opt/ghc/lib/ghc-8.0.2/transformers-0.5.2.0/libHStransformers-0.5.2.0-ghc8.0.2.dylib > > > > > > > > > >   Referenced from: /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-8.8/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSmtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6-ghc8.0.2.dylib > > > > > > > > > >   Reason: image not found) > > > > > > > > > > > > > > > > > > > > > > > > > > > > I tried to install transformers by calling `stack install transformers` but the problem still persisted. Is it because the version of transformers in my repo is different from the one referenced by `mtl` package? How should I fix it? > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Qingbo Liu > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > Beginners mailing list > > > > > > > > > Beginners at haskell.org > > > > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Beginners mailing list > > > > > > > Beginners at haskell.org > > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > _______________________________________________ > > > > > > Beginners mailing list > > > > > > Beginners at haskell.org > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > > > _______________________________________________ > > > > Beginners mailing list > > > > Beginners at haskell.org > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From mannyromero at mail.com Fri Dec 8 13:07:02 2017 From: mannyromero at mail.com (Manny Romero) Date: Fri, 8 Dec 2017 14:07:02 +0100 Subject: [Haskell-beginners] Monoid algebra Message-ID: An HTML attachment was scrubbed... URL: From mannyromero at mail.com Fri Dec 8 13:32:59 2017 From: mannyromero at mail.com (Manny Romero) Date: Fri, 8 Dec 2017 14:32:59 +0100 Subject: [Haskell-beginners] Addendum: Monoid algebra In-Reply-To: References: Message-ID: An HTML attachment was scrubbed... URL: From mannyromero at mail.com Fri Dec 8 13:36:46 2017 From: mannyromero at mail.com (Manny Romero) Date: Fri, 8 Dec 2017 14:36:46 +0100 Subject: [Haskell-beginners] Clarification (last one!): Monoid algebra In-Reply-To: References: Message-ID: An HTML attachment was scrubbed... URL: From quentin.liu.0415 at gmail.com Fri Dec 8 15:37:23 2017 From: quentin.liu.0415 at gmail.com (Quentin Liu) Date: Fri, 8 Dec 2017 10:37:23 -0500 Subject: [Haskell-beginners] Lost Monad Signature Message-ID: Hi, The function `join` flattens a double-layered monad into one layer and its type signature is   join :: (Monad m) => m (m a) -> m a But when the first argument supplied is `(,)`, the type signature becomes   join (,) :: b -> (b, b) in ghci. The monad constraint is lost when supplied the first argument. So my question is why the type constraint is lost and what monad is supplied here. Regards, Qingbo Liu -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Fri Dec 8 17:38:19 2017 From: aquagnu at gmail.com (Baa) Date: Fri, 8 Dec 2017 19:38:19 +0200 Subject: [Haskell-beginners] Template Haskell: simple way to "declare" type and instance Message-ID: <20171208193819.4f54fed3@Pavel> Hello, All! Is any way similar to templates (like in Crystal language, Rust, etc) to create `data X = ...`, `instance Show ...`, etc in TH? I found this tutorial https://wiki.haskell.org/A_practical_Template_Haskell_Tutorial but all looks complicated. Or something like Lisp macros, may be some modern library? Like quasy-quotations but for `data` and `instance` declarations (I don't know is it possible even) ? === Best regards, Paul From toad3k at gmail.com Fri Dec 8 18:10:49 2017 From: toad3k at gmail.com (David McBride) Date: Fri, 8 Dec 2017 13:10:49 -0500 Subject: [Haskell-beginners] Lost Monad Signature In-Reply-To: References: Message-ID: If you type :i Monad in ghci, you will see this instance instance Monad ((->) r) What this means is a function where the first argument is of type 'r'... is a monad. You can in fact use do notation / return on a tuple to manipulate its second argument monadically. So let's look at what that does to the type signature of join when 'm' is ((->) b) join :: Monad m => m (m a) -> m a -- m = ((->) b) join :: ((->) b ((->) b a)) -> (((->) b a)) Now we just have to move the arrows from prefix to infix. Let's do it step by step. join :: ((->) b (b -> a)) -> (b -> a) join :: (b -> (b -> a)) -> (b -> a) x -> (y -> z) is equivalent to x -> y -> z join :: (b -> b -> a) -> (b -> a) join :: (b -> b -> a) -> b -> a So now when you put an operator into it that takes two arguments (,) :: a -> b -> (a,b) You get the type you saw. join (,) :: b -> (b, b) On Fri, Dec 8, 2017 at 10:37 AM, Quentin Liu wrote: > Hi, > > The function `join` flattens a double-layered monad into one layer and its > type signature is > > join :: (Monad m) => m (m a) -> m a > > But when the first argument supplied is `(,)`, the type signature becomes > > join (,) :: b -> (b, b) > > in ghci. The monad constraint is lost when supplied the first argument. So > my question is why the type constraint is lost and what monad is supplied > here. > > Regards, > Qingbo Liu > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jays at panix.com Sat Dec 9 03:05:19 2017 From: jays at panix.com (Jay Sulzberger) Date: Fri, 8 Dec 2017 22:05:19 -0500 (EST) Subject: [Haskell-beginners] Clarification (last one!): Monoid algebra In-Reply-To: References: Message-ID: On Fri, 8 Dec 2017, Manny Romero wrote: > ***I meant the *unit* of the monoid free-forgetful monad, of course. > Sent: Friday, December 08, 2017 at 8:32 AM From: "Manny Romero" > To: beginners at haskell.org > Subject: [Haskell-beginners] Addendum: Monoid algebra > Clarification: I see now that an algebra is not, in fact, a natural > transformation, but rather a single morphism from an object's endofunctor > image back to the object itself. But my puzzlement still remains! If X = > {a, b, c}, then the monoid free-forgetful monad*** will map X to T X = > {[], [a], [b], [c], [a, a], [a,b], ... } in precisely the following way: > {a -> [a], b -> [b], c -> [c]}. How might a monoid algebra map TX back to > X ? Sent: Friday, December 08, 2017 at 8:07 AM From: "Manny Romero" Suppose we have a monoid X. The notation "X" is shorthand for the following set theoretic "struct": We have a set |X| called the carrier of X. For now suppose that |X| is always non-empty. We also have a collection of "terms", call them T(|X|), terms over |X|. The terms of X are specified by a collection of "names of operations". Let us call this collection NOO. Every kind of algebra, we are in the traditional Garrett Birkhoff setup, has its own NOO. So groups have this NOO { * of arity 2, ^-1 of arity 1, 1 of arity 0} Monoids have this NOO: { * of arity 2, 1 of arity 0} Rings have this NOO: { * of arity 2, 1 of arity 0, 0 of arity 0, + of arity 2, - of arity 1 } Note that the elements of any NOO are pairs of the form (name, non-negative integer). It is required of an NNO that every name appear exactly once in the NNO as the first element of the pair. The set of all such names is the set of names of "operations" of the algebra. These names are not, here type theory comes in, are not the actual operations of any particular algebra of our kind. (These "kinds" are not the "kinds" of Haskell.) OK, Let us now consider a particular algebra X. Assume X is of the kind Ring. Now what specifies X? X is specified by giving a map from the "terms of Ring kind over X" to |X|. OK, what is the "terms of Ring kind over |X|"? It is the smallest set, call it TR(|X|), which satisfies 1. Every element x of |X| is an element of TR(|X|). 2. If, for example, '+ is the name of the two place operation plus of the ring X, and a is an element of TR(|X|), and b is an element of TR(|X|), then so is the triple ('+, a, b). 2bis. Same for '0, '1, '*, '-. 3. To repeat, no other things are in TR(|X|), except as required by 1, 2, 2bis. Example: Let X be the ring of integers. Then the number 6, and the number 13, and the number minus2 are all in |X|. Here, using something like the usual high school notation, is an element of TR(|X|): ((- minus2) + (6 * ((13 + 13) + minus2))) which in the superior notation of Lisp is '(+ (- minus2) (* 6 (+ (+ 13 13) minus2))) The tick mark in front enforces that the thing is an actual term, and not the result of "evaluating" the term. Again, here is an ur example of real type theory: An un-evaluated term is an entirely different thing from the result of completely evaluating the term. It is also entirely different form the process of evaluating the term. Part of what makes learning the category theory somehow enturbulated with Haskell, is that one must first get such seemingly subtle and pointless distinctions clear. Of course programmers have an advantage over most students of mathematics: programmers can distinguish a file of code from the result of running the code, and also from the process of running the code. One lesson of category theory is that one can, if one has enough attachment points, one can attach many things. Every ridiculous distinction makes a crevice, which may be used as a line of attachment points. Higher order category theory admits the third and higher dimensions, Oi, my brain has been softened by reading too many "Introduction to Higher Category Theory, with Particular Attention to Haskell, BASIC, and absolute binary"s. IGNORE PREVIOUS SENTENCE. OK, so now let us explain what our example is, that is what further we need to define the ring X, let us now call it its usual name, namely "Z". Z has an underlying set, |Z|, some of whose members are minus117, 26, 403, 55, 403, 666, 2, minus2 Now the structure of Z as a ring is fully specified, once we have |Z|, and then TR(|Z|), by the most famous map in all of Lisp^WHaskell, the evaluation map, let us call it eval. Here is the type, ordinary ur sense, of eval for the ring Z: eval: TR(|Z|) -> |Z| That is, eval runs from the set of all ring terms over |Z| to |Z| its own self. Let is evaluate our example term:
> eval # "/usr/lib/scm/Init5f2.scm": (x) (#@@eval (#@@copy-tree #@x))> > (define minus2 -2) # > '(+ (- minus2) (* 6 (+ (+ 13 13) minus2))) (+ (- minus2) (* 6 (+ (+ 13 13) minus2))) > (eval '(+ (- minus2) (* 6 (+ (+ 13 13) minus2)))) 146 > (quit) Process scheme finished
Please forgive incomprehensible details, which appear due to traditional arrangements of the usual sort of Lisp repl. Let us repeat what we claim: The ring Z can be specified by giving its carrier |Z|, which is just the set of integers, and the set of ring terms TR(|Z|), and the map eval: TR(|Z|) -> |Z|. Now, because I realize that what I intended to write requires a few more pages, I break for now. What more is needed at this juncture is the structure of the "free ring on generators G", where G is just a set, and not the underlying set of any ring. One more remark: A ring is not any old X, with arbitrary |X|, and arbitrary eval: TR(|Z|) -> |Z|. A ring is required to obey "universal equations", also called "identities". Here is one ring identity: for any term t eval((* 1 t)) = eval t Oi, surface notation/syntax!, we have left out perhaps one, two, three maybe more tick marks, or not, oi. OK, this must be done better, but in high school notation^Wrhetoric the identity reads forall x (1 * x = x) Here implicitly the "variable x" ranges over all elements of |Z|, that is, the set of integers. Please forgive incomprehensibility, by reason of compression, of this squib! Perhaps more in a bit, perhaps just some pointers to stuff published on the Net. I remain, as ever, your fellow student of Haskell and Haskell blog posts, Jay Sulzberger > Sent: Friday, December 08, 2017 at 8:07 AM From: "Manny > Romero" To: beginners at haskell.org > Subject: [Haskell-beginners] Monoid algebra I'm having trouble > understanding the idea of an algebra using everybody's favorite > example, the monoid. What I want, to clarify, is to get some > intuition on characterizing the algebra of the free-forgetful > monoid adjunction. If F is the free monoid functor, and G is > its right adjoint, then G . F is our monad on SET; and its unit > eta is a natural transformation taking every set X to the set > (G . F) X ("set of words on the alphabet X") in such a way that > every element x in X is mapped to its "singleton word" > [x]. "Insertion of generators." I'm having trouble, on the > other hand, understanding how an algebra could establish a > natural transformation between the set (G . F) X for any set X, > back to X itself. How would those morphisms map the elements of > (G . F) X ? Aren't these algebras supposed to "represent" the > various monoids on X? But it isn't generally true that a monoid > operation maps back to the set of *generators*. I know I'm > missing something here, but what is it? Clarify these natural > transformations for me, in "mundane" "baby" monoid-describing > language! _______________________________________________ > Beginners mailing list Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > _______________________________________________ Beginners > mailing list Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From jays at panix.com Sat Dec 9 04:55:19 2017 From: jays at panix.com (Jay Sulzberger) Date: Fri, 8 Dec 2017 23:55:19 -0500 (EST) Subject: [Haskell-beginners] Clarification (last one!): Monoid algebra In-Reply-To: References: Message-ID: Ah, please forgive my skipping over an important part of the standard rant "what is an algebra?". In the earlier post, which appears below the cut line, we define a particular algebra X, of algebra kind K, where Kind K is specified by an NNO K-NNO (we wrongly ignore identities, relations, and such like) as a triple: X is given by (we here repeat, up to names, a paragraph of earlier post) as an algebra of Kind K, 1. a non-empty set |X| 2. the set TK(|X|) of terms with K-NNO as names of operators 3. the evaluation map of Kind K, for X, that is, this eval depends on X the actual "concrete algebra": eval: TK(|X|) -> |X| But the above is not Garrett Birkhoff's definition of an algebra of Kind K. Let us look at the Wikipedia article https://en.wikipedia.org/wiki/Universal_algebra [page was last edited on 7 December 2017, at 19:18] Here the concrete algebra X of Kind K is given by 1. a non-empty set |X| 2. for each ('op, op-arity) in K-NNO, same K-NNO as above, a map op: |X|^op-arity -> |X| and nothing more. No collection of terms in sight. Note that 'op is not the same as op. 'op is, to use Lisp terminology, just a symbol. op is a function with op-arity inputs and one output. op is everywhere defined and everywhere single-valued. In Lisp terms op is the value of 'op. Op is the value of 'op for the particular concrete algebra X. For a different concrete algebra, say Y, of Kind K, we will in general get a different op as the value of 'op. This second definition is the earlier definition. The two definitions give a cryptomorphism. From the first definition, using eval, for the concrete algebra X, we can get a definition, using the second definition, that is, using a list of named operations, of a type-theoretically different object, call it X2, which are however, for many purposes, but not all, really in some sense the same object. That is, X and X2 are cryptomorphic. Now I found last week a fine presentation of this by a distinguished type theorist, and, I will send the reference when, Heaven forwarding I find it again. Dear Beginners, Good Night and Happy Hacking! oo--JS. PS. Here is Philip Wadler's beautiful article on tick marks: @article{Wadler1987ACO, title={A critique of Abelson and Sussman or why calculating is better than scheming}, author={Philip Wadler}, journal={SIGPLAN Notices}, year={1987}, volume={22}, pages={83-94} } which today is at https://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf ---------------end new material------------------------------------------------- On Fri, 8 Dec 2017, Jay Sulzberger wrote: > > On Fri, 8 Dec 2017, Manny Romero wrote: > >> ***I meant the *unit* of the monoid free-forgetful monad, of course. >> Sent: Friday, December 08, 2017 at 8:32 AM From: "Manny Romero" >> To: beginners at haskell.org >> Subject: [Haskell-beginners] Addendum: Monoid algebra >> Clarification: I see now that an algebra is not, in fact, a natural >> transformation, but rather a single morphism from an object's endofunctor >> image back to the object itself. But my puzzlement still remains! If X = >> {a, b, c}, then the monoid free-forgetful monad*** will map X to T X = >> {[], [a], [b], [c], [a, a], [a,b], ... } in precisely the following way: >> {a -> [a], b -> [b], c -> [c]}. How might a monoid algebra map TX back to >> X ? Sent: Friday, December 08, 2017 at 8:07 AM From: "Manny Romero" > > Suppose we have a monoid X. The notation "X" is shorthand for the > following set theoretic "struct": > > We have a set |X| called the carrier of X. For now suppose > that |X| is always non-empty. We also have a collection of > "terms", call them T(|X|), terms over |X|. The terms of X are > specified by a collection of "names of operations". Let us > call this collection NOO. Every kind of algebra, we are in the > traditional Garrett Birkhoff setup, has its own NOO. So groups > have this NOO > > { * of arity 2, ^-1 of arity 1, 1 of arity 0} > > Monoids have this NOO: > > { * of arity 2, 1 of arity 0} > > Rings have this NOO: > > { * of arity 2, 1 of arity 0, 0 of arity 0, + of arity 2, - of arity 1 } > > Note that the elements of any NOO are pairs of the form (name, > non-negative integer). It is required of an NNO that every > name appear exactly once in the NNO as the first element of the > pair. The set of all such names is the set of names of > "operations" of the algebra. These names are not, here type > theory comes in, are not the actual operations of any > particular algebra of our kind. (These "kinds" are not the > "kinds" of Haskell.) > > OK, Let us now consider a particular algebra X. Assume X is of > the kind Ring. Now what specifies X? X is specified by giving > a map from the "terms of Ring kind over X" to |X|. OK, what is > the "terms of Ring kind over |X|"? It is the smallest set, > call it TR(|X|), which satisfies > > 1. Every element x of |X| is an element of TR(|X|). > > 2. If, for example, '+ is the name of the two place operation > plus of the ring X, and a is an element of TR(|X|), and > b is an element of TR(|X|), then so is the triple > ('+, a, b). > > 2bis. Same for '0, '1, '*, '-. > > 3. To repeat, no other things are in TR(|X|), except as required > by 1, 2, 2bis. > > Example: Let X be the ring of integers. Then the number 6, and > the number 13, and the number minus2 are all in |X|. Here, using > something like the usual high school notation, is an element of > TR(|X|): > > ((- minus2) + (6 * ((13 + 13) + minus2))) > > which in the superior notation of Lisp is > > '(+ (- minus2) (* 6 (+ (+ 13 13) minus2))) > > The tick mark in front enforces that the thing is an actual term, > and not the result of "evaluating" the term. Again, here is an > ur example of real type theory: An un-evaluated term is an > entirely different thing from the result of completely evaluating > the term. It is also entirely different form the process of > evaluating the term. Part of what makes learning the category > theory somehow enturbulated with Haskell, is that one must first > get such seemingly subtle and pointless distinctions clear. Of > course programmers have an advantage over most students of > mathematics: programmers can distinguish a file of code from the > result of running the code, and also from the process of running > the code. One lesson of category theory is that one can, if one > has enough attachment points, one can attach many things. Every > ridiculous distinction makes a crevice, which may be used as a > line of attachment points. Higher order category theory admits > the third and higher dimensions, Oi, my brain has been softened > by reading too many "Introduction to Higher Category Theory, with > Particular Attention to Haskell, BASIC, and absolute binary"s. > IGNORE PREVIOUS SENTENCE. > > OK, so now let us explain what our example is, that is what > further we need to define the ring X, let us now call it its > usual name, namely "Z". Z has an underlying set, |Z|, some of > whose members are > > minus117, 26, 403, 55, 403, 666, 2, minus2 > > Now the structure of Z as a ring is fully specified, once we have > |Z|, and then TR(|Z|), by the most famous map in all of > Lisp^WHaskell, the evaluation map, let us call it eval. Here is > the type, ordinary ur sense, of eval for the ring Z: > > eval: TR(|Z|) -> |Z| > > That is, eval runs from the set of all ring terms over |Z| to |Z| > its own self. > > Let is evaluate our example term: > >
what="example term evaluated using Aubrey Jaffer's scm, > with Jay Sulzberger's prelude, running atop > Emacs with quack loaded" > date="Friday 8 December 2017 21:46:01 -0500"> > > > eval > # "/usr/lib/scm/Init5f2.scm": (x) (#@@eval (#@@copy-tree > #@x))> > > (define minus2 -2) > # > > '(+ (- minus2) (* 6 (+ (+ 13 13) minus2))) > (+ (- minus2) (* 6 (+ (+ 13 13) minus2))) > > (eval '(+ (- minus2) (* 6 (+ (+ 13 13) minus2)))) > 146 > > (quit) > > Process scheme finished > >
> > Please forgive incomprehensible details, which appear due to > traditional arrangements of the usual sort of Lisp repl. > > Let us repeat what we claim: > > The ring Z can be specified by giving its carrier |Z|, which is just > the set of integers, and the set of ring terms TR(|Z|), and the map > eval: TR(|Z|) -> |Z|. > > Now, because I realize that what I intended to write requires a > few more pages, I break for now. What more is needed at this > juncture is the structure of the "free ring on generators G", > where G is just a set, and not the underlying set of any ring. > > One more remark: A ring is not any old X, with arbitrary |X|, and > arbitrary eval: TR(|Z|) -> |Z|. A ring is required to obey > "universal equations", also called "identities". Here is one ring identity: > > for any term t > > eval((* 1 t)) = eval t > > Oi, surface notation/syntax!, we have left out perhaps one, two, > three maybe more tick marks, or not, oi. OK, this must be done > better, but in high school notation^Wrhetoric the identity reads > > forall x (1 * x = x) > > Here implicitly the "variable x" ranges over all elements of |Z|, > that is, the set of integers. > > Please forgive incomprehensibility, by reason of compression, of > this squib! > > Perhaps more in a bit, perhaps just some pointers to stuff > published on the Net. > > I remain, as ever, your fellow student of Haskell and Haskell blog posts, > Jay Sulzberger > > > >> Sent: Friday, December 08, 2017 at 8:07 AM From: "Manny >> Romero" To: beginners at haskell.org >> Subject: [Haskell-beginners] Monoid algebra I'm having trouble >> understanding the idea of an algebra using everybody's favorite >> example, the monoid. What I want, to clarify, is to get some >> intuition on characterizing the algebra of the free-forgetful >> monoid adjunction. If F is the free monoid functor, and G is >> its right adjoint, then G . F is our monad on SET; and its unit >> eta is a natural transformation taking every set X to the set >> (G . F) X ("set of words on the alphabet X") in such a way that >> every element x in X is mapped to its "singleton word" >> [x]. "Insertion of generators." I'm having trouble, on the >> other hand, understanding how an algebra could establish a >> natural transformation between the set (G . F) X for any set X, >> back to X itself. How would those morphisms map the elements of >> (G . F) X ? Aren't these algebras supposed to "represent" the >> various monoids on X? But it isn't generally true that a monoid >> operation maps back to the set of *generators*. I know I'm >> missing something here, but what is it? Clarify these natural >> transformations for me, in "mundane" "baby" monoid-describing >> language! _______________________________________________ >> Beginners mailing list Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> _______________________________________________ Beginners >> mailing list Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From quentin.liu.0415 at gmail.com Sat Dec 9 21:29:13 2017 From: quentin.liu.0415 at gmail.com (Quentin Liu) Date: Sat, 9 Dec 2017 16:29:13 -0500 Subject: [Haskell-beginners] Lost Monad Signature In-Reply-To: References: Message-ID: <36e26a32-8617-484e-a334-84ee582af598@Spark> Thanks for the explanation. But why did Haskell pick up the Reader monad in particular? Is this part of the HM type inference rule? Regards, Qingbo Liu On Dec 8, 2017, 13:12 -0500, David McBride , wrote: > If you type :i Monad in ghci, you will see this instance > > instance Monad ((->) r) > > What this means is a function where the first argument is of type 'r'... is a monad.  You can in fact use do notation / return on a tuple to manipulate its second argument monadically. > > So let's look at what that does to the type signature of join when 'm' is ((->) b) > > join :: Monad m => m (m a) -> m a > >  -- m = ((->) b) > > join :: ((->) b ((->) b a)) -> (((->) b a)) > > Now we just have to move the arrows from prefix to infix.  Let's do it step by step. > > join :: ((->) b (b -> a)) -> (b -> a) > join :: (b -> (b -> a)) -> (b -> a) > > x -> (y -> z) is equivalent to x -> y -> z > > join :: (b -> b -> a) -> (b -> a) > join :: (b -> b -> a) -> b -> a > > So now when you put an operator into it that takes two arguments > > (,) :: a -> b -> (a,b) > > You get the type you saw. > > join (,) :: b -> (b, b) > > > > > > > On Fri, Dec 8, 2017 at 10:37 AM, Quentin Liu wrote: > > > Hi, > > > > > > The function `join` flattens a double-layered monad into one layer and its type signature is > > > > > >   join :: (Monad m) => m (m a) -> m a > > > > > > But when the first argument supplied is `(,)`, the type signature becomes > > > > > >   join (,) :: b -> (b, b) > > > > > > in ghci. The monad constraint is lost when supplied the first argument. So my question is why the type constraint is lost and what monad is supplied here. > > > > > > Regards, > > > Qingbo Liu > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Mon Dec 11 11:04:33 2017 From: aquagnu at gmail.com (Baa) Date: Mon, 11 Dec 2017 13:04:33 +0200 Subject: [Haskell-beginners] How to call constructor from Template Haskell Message-ID: <20171211130433.6e191c18@Pavel> Hello All! I have function which constructs some data type. It has signature `Name -> Q [Dec]`. Somewhere in its body I'm extracting constructors of some type with pattern-matching: case tyCons of DataD ctx nm tyVars mbKind cs derivs -> ... Type of those constructors `cs` instantiates some class like this: class MyClass a where specialValue :: a So, I'm iterating over those `cs` but I want to skip one of them which is equal to `specialValue`. Something like this: [c | c <- cs, c /= specialValue] How to do this with Template Haskell's `Con` type (`c`::Con) - I can't call it to compare created value with a `specialValue` ? === Best regards, Paul From aquagnu at gmail.com Mon Dec 11 16:39:00 2017 From: aquagnu at gmail.com (Baa) Date: Mon, 11 Dec 2017 18:39:00 +0200 Subject: [Haskell-beginners] What does 'impossible happened' mean? Message-ID: <20171211183900.220fd445@Pavel> Hello, List. I hit error: ghc: panic! (the 'impossible' happened) (GHC version 8.0.2 for x86_64-unknown-linux): initTc: unsolved constraints WC {wc_insol = [W] spec_a86e :: t_a86d[tau:1] (CHoleCan: spec)} Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug what does it mean and how to fix it? PS. I only added template Haskell "call" in my test suite like $(blahBlah something) The same call works fine in other modules and in GHCI. "stack build" works too, but tests - no (last stack 1.6.1) === Best regards, Paul From toad3k at gmail.com Mon Dec 11 16:43:24 2017 From: toad3k at gmail.com (David McBride) Date: Mon, 11 Dec 2017 11:43:24 -0500 Subject: [Haskell-beginners] What does 'impossible happened' mean? In-Reply-To: <20171211183900.220fd445@Pavel> References: <20171211183900.220fd445@Pavel> Message-ID: It may be a bug in ghc. It may be a bug in stack. Not much you can do about it other than to report it. On Mon, Dec 11, 2017 at 11:39 AM, Baa wrote: > Hello, List. I hit error: > > ghc: panic! (the 'impossible' happened) > (GHC version 8.0.2 for x86_64-unknown-linux): > initTc: unsolved constraints > WC {wc_insol = [W] spec_a86e :: t_a86d[tau:1] (CHoleCan: spec)} > > Please report this as a GHC bug: http://www.haskell.org/ghc/ > reportabug > > what does it mean and how to fix it? > > PS. I only added template Haskell "call" in my test suite like > > $(blahBlah something) > > The same call works fine in other modules and in GHCI. "stack build" > works too, but tests - no (last stack 1.6.1) > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Mon Dec 11 16:45:02 2017 From: toad3k at gmail.com (David McBride) Date: Mon, 11 Dec 2017 11:45:02 -0500 Subject: [Haskell-beginners] What does 'impossible happened' mean? In-Reply-To: References: <20171211183900.220fd445@Pavel> Message-ID: And I should say, you might try a newer ghc, they fix things all the time. Stack is still on ghc 8.0.2, but newer snapshots are on 8.2.2. On Mon, Dec 11, 2017 at 11:43 AM, David McBride wrote: > It may be a bug in ghc. It may be a bug in stack. Not much you can do > about it other than to report it. > > On Mon, Dec 11, 2017 at 11:39 AM, Baa wrote: > >> Hello, List. I hit error: >> >> ghc: panic! (the 'impossible' happened) >> (GHC version 8.0.2 for x86_64-unknown-linux): >> initTc: unsolved constraints >> WC {wc_insol = [W] spec_a86e :: t_a86d[tau:1] (CHoleCan: spec)} >> >> Please report this as a GHC bug: http://www.haskell.org/ghc/rep >> ortabug >> >> what does it mean and how to fix it? >> >> PS. I only added template Haskell "call" in my test suite like >> >> $(blahBlah something) >> >> The same call works fine in other modules and in GHCI. "stack build" >> works too, but tests - no (last stack 1.6.1) >> >> === >> Best regards, Paul >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Mon Dec 11 17:15:14 2017 From: aquagnu at gmail.com (Baa) Date: Mon, 11 Dec 2017 19:15:14 +0200 Subject: [Haskell-beginners] What does 'impossible happened' mean? In-Reply-To: References: <20171211183900.220fd445@Pavel> Message-ID: <20171211191514.6bf84519@Pavel> Hello, David. Something new :) So, 1. How to report such bug? 2. How to upgrade to 8.2.2 and to new LTS? I tried to change "resolve: lts-XX" to "resolve: ghc-8.2.2" in stack.yaml but hit many errors. > And I should say, you might try a newer ghc, they fix things all the > time. Stack is still on ghc 8.0.2, but newer snapshots are on 8.2.2. > > On Mon, Dec 11, 2017 at 11:43 AM, David McBride > wrote: > > > It may be a bug in ghc. It may be a bug in stack. Not much you > > can do about it other than to report it. > > > > On Mon, Dec 11, 2017 at 11:39 AM, Baa wrote: > > > >> Hello, List. I hit error: > >> > >> ghc: panic! (the 'impossible' happened) > >> (GHC version 8.0.2 for x86_64-unknown-linux): > >> initTc: unsolved constraints > >> WC {wc_insol = [W] spec_a86e :: t_a86d[tau:1] (CHoleCan: > >> spec)} > >> > >> Please report this as a GHC bug: > >> http://www.haskell.org/ghc/rep ortabug > >> > >> what does it mean and how to fix it? > >> > >> PS. I only added template Haskell "call" in my test suite like > >> > >> $(blahBlah something) > >> > >> The same call works fine in other modules and in GHCI. "stack > >> build" works too, but tests - no (last stack 1.6.1) > >> > >> === > >> Best regards, Paul > >> _______________________________________________ > >> Beginners mailing list > >> Beginners at haskell.org > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > >> > > > > From toad3k at gmail.com Mon Dec 11 17:30:44 2017 From: toad3k at gmail.com (David McBride) Date: Mon, 11 Dec 2017 12:30:44 -0500 Subject: [Haskell-beginners] What does 'impossible happened' mean? In-Reply-To: <20171211191514.6bf84519@Pavel> References: <20171211183900.220fd445@Pavel> <20171211191514.6bf84519@Pavel> Message-ID: It is all detailed in the error message. http://www.haskell.org/ghc/reportabug On Mon, Dec 11, 2017 at 12:15 PM, Baa wrote: > Hello, David. > Something new :) So, > > 1. How to report such bug? > 2. How to upgrade to 8.2.2 and to new LTS? > I tried to change "resolve: lts-XX" to "resolve: ghc-8.2.2" in > stack.yaml but hit many errors. > > > > And I should say, you might try a newer ghc, they fix things all the > > time. Stack is still on ghc 8.0.2, but newer snapshots are on 8.2.2. > > > > On Mon, Dec 11, 2017 at 11:43 AM, David McBride > > wrote: > > > > > It may be a bug in ghc. It may be a bug in stack. Not much you > > > can do about it other than to report it. > > > > > > On Mon, Dec 11, 2017 at 11:39 AM, Baa wrote: > > > > > >> Hello, List. I hit error: > > >> > > >> ghc: panic! (the 'impossible' happened) > > >> (GHC version 8.0.2 for x86_64-unknown-linux): > > >> initTc: unsolved constraints > > >> WC {wc_insol = [W] spec_a86e :: t_a86d[tau:1] (CHoleCan: > > >> spec)} > > >> > > >> Please report this as a GHC bug: > > >> http://www.haskell.org/ghc/rep ortabug > > >> > > >> what does it mean and how to fix it? > > >> > > >> PS. I only added template Haskell "call" in my test suite like > > >> > > >> $(blahBlah something) > > >> > > >> The same call works fine in other modules and in GHCI. "stack > > >> build" works too, but tests - no (last stack 1.6.1) > > >> > > >> === > > >> Best regards, Paul > > >> _______________________________________________ > > >> Beginners mailing list > > >> Beginners at haskell.org > > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > >> > > > > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike_k_houghton at yahoo.co.uk Mon Dec 11 20:56:28 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Mon, 11 Dec 2017 20:56:28 +0000 Subject: [Haskell-beginners] IO question Message-ID: <2F486570-EE98-45CA-8880-6B24EABAFA53@yahoo.co.uk> I have input <- readFile “data.txt” let input’ = splitOn “,” input …. How do I make that into just one line? Thanks Mike From toad3k at gmail.com Mon Dec 11 21:00:02 2017 From: toad3k at gmail.com (David McBride) Date: Mon, 11 Dec 2017 16:00:02 -0500 Subject: [Haskell-beginners] IO question In-Reply-To: <2F486570-EE98-45CA-8880-6B24EABAFA53@yahoo.co.uk> References: <2F486570-EE98-45CA-8880-6B24EABAFA53@yahoo.co.uk> Message-ID: splitOn "," <$> readFile "data.txt" or perhaps readFile "data.txt" >>= return . splitOn "," On Mon, Dec 11, 2017 at 3:56 PM, mike h wrote: > I have > > input <- readFile “data.txt” > let input’ = splitOn “,” input > …. > > How do I make that into just one line? > > Thanks > > Mike > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike_k_houghton at yahoo.co.uk Mon Dec 11 21:24:05 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Mon, 11 Dec 2017 21:24:05 +0000 Subject: [Haskell-beginners] IO question In-Reply-To: References: <2F486570-EE98-45CA-8880-6B24EABAFA53@yahoo.co.uk> Message-ID: Thank you David. Before posting I tried readFile "data.txt" >>= … but got errors as I didn’t use return.!! Mike > On 11 Dec 2017, at 21:00, David McBride wrote: > > splitOn "," <$> readFile "data.txt" > > or perhaps > > readFile "data.txt" >>= return . splitOn "," > > On Mon, Dec 11, 2017 at 3:56 PM, mike h > wrote: > I have > > input <- readFile “data.txt” > let input’ = splitOn “,” input > …. > > How do I make that into just one line? > > Thanks > > Mike > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Tue Dec 12 11:56:03 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 13:56:03 +0200 Subject: [Haskell-beginners] How to install new GHC ? Message-ID: <20171212135603.61ee055f@Pavel> Hello, All, I want to switch to the new GHC (8.2.2) because I hit some bug in GHC and suppose that it may be fixed in the new version. So, to try it I changed "resolver: XXX" in my .yaml-files to "lts-9.18". Also I done something else (I don't remember what exactly) and call `stack setup ... --reinstall ...`. New GHC have been installed. And I switched to new LTS - I see it 100%. But when I run `stack build`, IMHO compiller is old, because if I call `stack ghci` I see that old GHC (8.0.2) is calling. I'm not familiar with stack/Haskell tools in-depth and may miss something! For example, I know that LTS-9.18 is last stable, GHC 8.2.2 is last too, but in Stackage seems that 9.18 corresponds to 8.2.2. If I run `stack setup` in the directory with my project again I get: --cut-- stack will use a sandboxed GHC it installed For more information on paths, see 'stack path' and 'stack exec env' To use this GHC and packages outside of a project, consider using: stack ghc, stack ghci, stack runghc, or stack exec --cut-- Would somebody explain me what is wrong here and how I can test a project with new 8.2.2 GHC? === Best regards, Paul From sylvain at haskus.fr Tue Dec 12 12:02:49 2017 From: sylvain at haskus.fr (Sylvain Henry) Date: Tue, 12 Dec 2017 13:02:49 +0100 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212135603.61ee055f@Pavel> References: <20171212135603.61ee055f@Pavel> Message-ID: Hi, LTS-9.18 uses GHC 8.0.2. You can try a nightly resolver to test GHC 8.2.2, e.g. https://www.stackage.org/nightly-2017-12-10 Sylvain On 12/12/2017 12:56, Baa wrote: > Hello, All, > > I want to switch to the new GHC (8.2.2) because I hit some > bug in GHC and suppose that it may be fixed in the new version. So, to > try it I changed "resolver: XXX" in my .yaml-files to "lts-9.18". Also I > done something else (I don't remember what exactly) and call > `stack setup ... --reinstall ...`. New GHC have been installed. And I > switched to new LTS - I see it 100%. > But when I run `stack build`, IMHO compiller is old, because if I call > `stack ghci` I see that old GHC (8.0.2) is calling. I'm not familiar > with stack/Haskell tools in-depth and may miss something! For example, > I know that LTS-9.18 is last stable, GHC 8.2.2 is last too, but in > Stackage seems that 9.18 corresponds to 8.2.2. > > If I run `stack setup` in the directory with my project again I get: > > --cut-- > stack will use a sandboxed GHC it installed > For more information on paths, see 'stack path' and 'stack exec env' > To use this GHC and packages outside of a project, consider using: > stack ghc, stack ghci, stack runghc, or stack exec > --cut-- > > Would somebody explain me what is wrong here and how I can test a > project with new 8.2.2 GHC? > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From fa-ml at ariis.it Tue Dec 12 12:09:15 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 12 Dec 2017 13:09:15 +0100 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212135603.61ee055f@Pavel> References: <20171212135603.61ee055f@Pavel> Message-ID: <20171212120915.6epux6bhnx4gbn62@x60s.casa> On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > Would somebody explain me what is wrong here and how I can test a > project with new 8.2.2 GHC? Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a nightly or download/install ghc from here and compile your project with the new `cabal new-build`. [1] https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries From aquagnu at gmail.com Tue Dec 12 12:53:47 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 14:53:47 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212120915.6epux6bhnx4gbn62@x60s.casa> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> Message-ID: <20171212145347.5e211ff2@Pavel> @Francesco: unfortunately nightly misses some package. So, I tried: $ stack --resolver=ghc-8.2.2 setup --reinstall Preparing to install GHC (tinfo6) to an isolated location. This will not interfere with any system-level installation. Already downloaded. Installed GHC. stack will use a sandboxed GHC it installed For more information on paths, see 'stack path' and 'stack exec env' To use this GHC and packages outside of a project, consider using: stack ghc, stack ghci, stack runghc, or stack exec So seems that 8.2.2 was installed, right? But how to build the project with new GHC now? I never used cabal before, `stack ghci` still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not correspond to .yaml file LTS - maybe this is a reason why old 8.0.2 is stil used... When I try cabal build/new-build/repl I get: cabal: The program 'ghc' version >=6.4 is required but it could not be found. So, cabal does not know about installed GHC versions (at least 8.0.2, used by stack). I tried --require-sandbox but without success. > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > Would somebody explain me what is wrong here and how I can test a > > project with new 8.2.2 GHC? > > Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a > nightly or download/install ghc from here and compile your project > with the new `cabal new-build`. > > [1] https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From toad3k at gmail.com Tue Dec 12 13:16:44 2017 From: toad3k at gmail.com (David McBride) Date: Tue, 12 Dec 2017 08:16:44 -0500 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212145347.5e211ff2@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> Message-ID: You can see how to configure stack here: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md The short of it is that to have stack ghci choose a particular version of ghc, you probably need to modify ~/.stack/global/stack.yaml, change resolver to something here https://www.stackage.org/snapshots that has your version of ghc and dependencies similar to what your project wants. For example 'nightly-2017-12-10'. On Tue, Dec 12, 2017 at 7:53 AM, Baa wrote: > @Francesco: unfortunately nightly misses some package. So, I tried: > > $ stack --resolver=ghc-8.2.2 setup --reinstall > Preparing to install GHC (tinfo6) to an isolated location. This will not > interfere with any system-level installation. Already downloaded. > Installed GHC. > > stack will use a sandboxed GHC it installed > For more information on paths, see 'stack path' and 'stack exec env' > To use this GHC and packages outside of a project, consider using: > stack ghc, stack ghci, stack runghc, or stack exec > > So seems that 8.2.2 was installed, right? But how to build the project > with new GHC now? I never used cabal before, `stack ghci` still runs > 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not correspond > to .yaml file LTS - maybe this is a reason why old 8.0.2 is stil used... > > When I try cabal build/new-build/repl I get: > > cabal: The program 'ghc' version >=6.4 is required but it could not be > found. > > So, cabal does not know about installed GHC versions (at least 8.0.2, > used by stack). I tried --require-sandbox but without success. > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > Would somebody explain me what is wrong here and how I can test a > > > project with new 8.2.2 GHC? > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a > > nightly or download/install ghc from here and compile your project > > with the new `cabal new-build`. > > > > [1] https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Tue Dec 12 13:18:50 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 12 Dec 2017 14:18:50 +0100 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212145347.5e211ff2@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> Message-ID: <20171212131850.eaqdnm6jopreeall@x60s.casa> On Tue, Dec 12, 2017 at 02:53:47PM +0200, Baa wrote: > @Francesco: unfortunately nightly misses some package. So, I tried: > > $ stack --resolver=ghc-8.2.2 setup --reinstall > Preparing to install GHC (tinfo6) to an isolated location. This will not > interfere with any system-level installation. Already downloaded. > Installed GHC. > > stack will use a sandboxed GHC it installed > For more information on paths, see 'stack path' and 'stack exec env' > To use this GHC and packages outside of a project, consider using: > stack ghc, stack ghci, stack runghc, or stack exec > > So seems that 8.2.2 was installed, right? But how to build the project > with new GHC now? I never used cabal before, `stack ghci` still runs > 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not correspond > to .yaml file LTS - maybe this is a reason why old 8.0.2 is stil used... > > When I try cabal build/new-build/repl I get: > > cabal: The program 'ghc' version >=6.4 is required but it could not be > found. > > So, cabal does not know about installed GHC versions (at least 8.0.2, > used by stack). I tried --require-sandbox but without success. Hey Paul, four-step plan: 1. check where stack installed ghc, it should be something like: ~/.stack/programs/x86_32-linux/ghc-nopie-8.2.1/lib/ghc-8.2.1/bin 2. add these two lines to your `~/.bashrc`: export PATH=~/.cabal/bin:$PATH # path to stuff built with cabal export PATH=~/the.stackpathabove:$PATH # path to ghc 3. check the right ghc version has been selected: ghc -v # should be 8.2.2 4. cd into your project and `cabal new-build` and then open a repl on it with `cabal new-repl`. Let us know if this works! From aquagnu at gmail.com Tue Dec 12 13:38:30 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 15:38:30 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212131850.eaqdnm6jopreeall@x60s.casa> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212131850.eaqdnm6jopreeall@x60s.casa> Message-ID: <20171212153830.7425ca8f@Pavel> 1. GHC 8.2.2 is here: ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.2/bin 2. done 3. yes, it's 8.2.2 4. `cabal new-build` said to me call `cabal update`, I done it, then run it again and got: $ cabal new-build Resolving dependencies... cabal: Could not resolve dependencies: trying: XXX-0.5.0.0 (user goal) next goal: YYY-utils (dependency of XXX-0.5.0.0) Dependency tree exhaustively searched. > On Tue, Dec 12, 2017 at 02:53:47PM +0200, Baa wrote: > > @Francesco: unfortunately nightly misses some package. So, I tried: > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > Preparing to install GHC (tinfo6) to an isolated location. This > > will not interfere with any system-level installation. Already > > downloaded. Installed GHC. > > > > stack will use a sandboxed GHC it installed > > For more information on paths, see 'stack path' and 'stack exec > > env' To use this GHC and packages outside of a project, consider > > using: stack ghc, stack ghci, stack runghc, or stack exec > > > > So seems that 8.2.2 was installed, right? But how to build the > > project with new GHC now? I never used cabal before, `stack ghci` > > still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not > > correspond to .yaml file LTS - maybe this is a reason why old 8.0.2 > > is stil used... > > > > When I try cabal build/new-build/repl I get: > > > > cabal: The program 'ghc' version >=6.4 is required but it could > > not be found. > > > > So, cabal does not know about installed GHC versions (at least > > 8.0.2, used by stack). I tried --require-sandbox but without > > success. > > Hey Paul, > four-step plan: > > 1. check where stack installed ghc, it should be something like: > > ~/.stack/programs/x86_32-linux/ghc-nopie-8.2.1/lib/ghc-8.2.1/bin > > 2. add these two lines to your `~/.bashrc`: > > export PATH=~/.cabal/bin:$PATH # path to stuff built with cabal > export PATH=~/the.stackpathabove:$PATH # path to ghc > > 3. check the right ghc version has been selected: > > ghc -v > # should be 8.2.2 > > 4. cd into your project and `cabal new-build` and then open a repl on > it with `cabal new-repl`. > > Let us know if this works! > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From aquagnu at gmail.com Tue Dec 12 13:43:45 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 15:43:45 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> Message-ID: <20171212154345.083ddfa0@Pavel> @David: I tried to switch to nightly but in project's .yaml file and got error about missing of some library (as I understand, it is missing in last nightly). So, if I try to do it through .yaml file then how to use new GHC (8.2.2) but with LTS for 8.0.2? Is it possible? I need last stable LTS where all libraries (using in the projects) exist, but with new GHC 8.2.2 which is too new for stable LTS. As I read somewhere, GHC version and Stackage version are linked together hardly in stack tool, or? > You can see how to configure stack here: > https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md > > The short of it is that to have stack ghci choose a particular > version of ghc, you probably need to modify > ~/.stack/global/stack.yaml, change resolver to something here > https://www.stackage.org/snapshots that has your version of ghc and > dependencies similar to what your project wants. For example > 'nightly-2017-12-10'. > > On Tue, Dec 12, 2017 at 7:53 AM, Baa wrote: > > > @Francesco: unfortunately nightly misses some package. So, I tried: > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > Preparing to install GHC (tinfo6) to an isolated location. This > > will not interfere with any system-level installation. Already > > downloaded. Installed GHC. > > > > stack will use a sandboxed GHC it installed > > For more information on paths, see 'stack path' and 'stack exec > > env' To use this GHC and packages outside of a project, consider > > using: stack ghc, stack ghci, stack runghc, or stack exec > > > > So seems that 8.2.2 was installed, right? But how to build the > > project with new GHC now? I never used cabal before, `stack ghci` > > still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not > > correspond to .yaml file LTS - maybe this is a reason why old 8.0.2 > > is stil used... > > > > When I try cabal build/new-build/repl I get: > > > > cabal: The program 'ghc' version >=6.4 is required but it could > > not be found. > > > > So, cabal does not know about installed GHC versions (at least > > 8.0.2, used by stack). I tried --require-sandbox but without > > success. > > > > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > > Would somebody explain me what is wrong here and how I can test > > > > a project with new 8.2.2 GHC? > > > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a > > > nightly or download/install ghc from here and compile your project > > > with the new `cabal new-build`. > > > > > > [1] https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From fa-ml at ariis.it Tue Dec 12 13:51:18 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 12 Dec 2017 14:51:18 +0100 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212153830.7425ca8f@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212131850.eaqdnm6jopreeall@x60s.casa> <20171212153830.7425ca8f@Pavel> Message-ID: <20171212135118.bk24obonpzb7wfen@x60s.casa> On Tue, Dec 12, 2017 at 03:38:30PM +0200, Baa wrote: > 1. GHC 8.2.2 is here: > ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.2/bin > 2. done > 3. yes, it's 8.2.2 > 4. `cabal new-build` said to me call `cabal update`, I done it, then run > it again and got: > $ cabal new-build > Resolving dependencies... > cabal: Could not resolve dependencies: > trying: XXX-0.5.0.0 (user goal) > next goal: YYY-utils (dependency of XXX-0.5.0.0) > Dependency tree exhaustively searched. Good, we're almost there! I strongly suspect it is a base constraint. Go in your something.cabal file, build-depends section(s) and modify it from: base >= 4.somenumber && < 4.10 to base >= 4.somenumber && < 4.11 And try cabal new-build again. If that fails, please include the content of your `build-depends:` portion in your message -F From toad3k at gmail.com Tue Dec 12 13:54:46 2017 From: toad3k at gmail.com (David McBride) Date: Tue, 12 Dec 2017 08:54:46 -0500 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212154345.083ddfa0@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212154345.083ddfa0@Pavel> Message-ID: This is just trending into how to a stack tutorial. But to use stack in your project you generate a stack.yaml file. In that file you can put in the extra-deps stanza something like this: extra-deps: - process-streaming-0.9.1.2 - conceit-0.4.0.0 - pipes-transduce-0.4 - haskell-asterisk-types-0.1.0.0 - haskell-asterisk-0.2.0.0 - haskell-restapi-spec-0.1.0.0 Basically you list specific versions of programs that are not in stackage, and they will be pulled from hackage, if they exist. But you are still at the mercy of version bounds. If a package you need doesn't work with a newer ghc (which would explain why it isn't in nightly) or some other package you are using, you are out of luck. On Tue, Dec 12, 2017 at 8:43 AM, Baa wrote: > @David: I tried to switch to nightly but in project's .yaml file and > got error about missing of some library (as I understand, it is missing > in last nightly). So, if I try to do it through .yaml file then how to > use new GHC (8.2.2) but with LTS for 8.0.2? Is it possible? I need last > stable LTS where all libraries (using in the projects) exist, but with > new GHC 8.2.2 which is too new for stable LTS. As I read somewhere, GHC > version and Stackage version are linked together hardly in stack tool, > or? > > > You can see how to configure stack here: > > https://github.com/commercialhaskell/stack/blob/release/doc/yaml_ > configuration.md > > > > The short of it is that to have stack ghci choose a particular > > version of ghc, you probably need to modify > > ~/.stack/global/stack.yaml, change resolver to something here > > https://www.stackage.org/snapshots that has your version of ghc and > > dependencies similar to what your project wants. For example > > 'nightly-2017-12-10'. > > > > On Tue, Dec 12, 2017 at 7:53 AM, Baa wrote: > > > > > @Francesco: unfortunately nightly misses some package. So, I tried: > > > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > > Preparing to install GHC (tinfo6) to an isolated location. This > > > will not interfere with any system-level installation. Already > > > downloaded. Installed GHC. > > > > > > stack will use a sandboxed GHC it installed > > > For more information on paths, see 'stack path' and 'stack exec > > > env' To use this GHC and packages outside of a project, consider > > > using: stack ghc, stack ghci, stack runghc, or stack exec > > > > > > So seems that 8.2.2 was installed, right? But how to build the > > > project with new GHC now? I never used cabal before, `stack ghci` > > > still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not > > > correspond to .yaml file LTS - maybe this is a reason why old 8.0.2 > > > is stil used... > > > > > > When I try cabal build/new-build/repl I get: > > > > > > cabal: The program 'ghc' version >=6.4 is required but it could > > > not be found. > > > > > > So, cabal does not know about installed GHC versions (at least > > > 8.0.2, used by stack). I tried --require-sandbox but without > > > success. > > > > > > > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > > > Would somebody explain me what is wrong here and how I can test > > > > > a project with new 8.2.2 GHC? > > > > > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a > > > > nightly or download/install ghc from here and compile your project > > > > with the new `cabal new-build`. > > > > > > > > [1] https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > > > > > > > _______________________________________________ > > > > Beginners mailing list > > > > Beginners at haskell.org > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Tue Dec 12 13:54:38 2017 From: michael at snoyman.com (Michael Snoyman) Date: Tue, 12 Dec 2017 15:54:38 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212154345.083ddfa0@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212154345.083ddfa0@Pavel> Message-ID: Hi Paul, A Stackage snapshot specifies both a GHC version and a set of packages. Stackage snapshots are built and tested to ensure that the packages are compatible. While you could tell Stack to use a different GHC version with a snapshot[1], this is unlikely to work, since GHC major releases usually break some packages. I think everyone who's trying to help you (both with Cabal and Stack workflows) would be able to do so better if you explain which package you're trying to use which is no longer available in Stackage Nightly. In some cases, you can simply add it as an extra dependencies for Stack (e.g., `extra-deps: [acme-missiles-0.3]`), while in others there is some inherent incompatibility. Right now, you'll just be getting guesses about how to theoretically get some unknown package to build with a bunch of others. Michael [1] Using a setting like `compiler: ghc-8.2.2` On Tue, Dec 12, 2017 at 3:43 PM, Baa wrote: > @David: I tried to switch to nightly but in project's .yaml file and > got error about missing of some library (as I understand, it is missing > in last nightly). So, if I try to do it through .yaml file then how to > use new GHC (8.2.2) but with LTS for 8.0.2? Is it possible? I need last > stable LTS where all libraries (using in the projects) exist, but with > new GHC 8.2.2 which is too new for stable LTS. As I read somewhere, GHC > version and Stackage version are linked together hardly in stack tool, > or? > > > You can see how to configure stack here: > > https://github.com/commercialhaskell/stack/blob/release/doc/yaml_ > configuration.md > > > > The short of it is that to have stack ghci choose a particular > > version of ghc, you probably need to modify > > ~/.stack/global/stack.yaml, change resolver to something here > > https://www.stackage.org/snapshots that has your version of ghc and > > dependencies similar to what your project wants. For example > > 'nightly-2017-12-10'. > > > > On Tue, Dec 12, 2017 at 7:53 AM, Baa wrote: > > > > > @Francesco: unfortunately nightly misses some package. So, I tried: > > > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > > Preparing to install GHC (tinfo6) to an isolated location. This > > > will not interfere with any system-level installation. Already > > > downloaded. Installed GHC. > > > > > > stack will use a sandboxed GHC it installed > > > For more information on paths, see 'stack path' and 'stack exec > > > env' To use this GHC and packages outside of a project, consider > > > using: stack ghc, stack ghci, stack runghc, or stack exec > > > > > > So seems that 8.2.2 was installed, right? But how to build the > > > project with new GHC now? I never used cabal before, `stack ghci` > > > still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not > > > correspond to .yaml file LTS - maybe this is a reason why old 8.0.2 > > > is stil used... > > > > > > When I try cabal build/new-build/repl I get: > > > > > > cabal: The program 'ghc' version >=6.4 is required but it could > > > not be found. > > > > > > So, cabal does not know about installed GHC versions (at least > > > 8.0.2, used by stack). I tried --require-sandbox but without > > > success. > > > > > > > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > > > Would somebody explain me what is wrong here and how I can test > > > > > a project with new 8.2.2 GHC? > > > > > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a > > > > nightly or download/install ghc from here and compile your project > > > > with the new `cabal new-build`. > > > > > > > > [1] https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > > > > > > > _______________________________________________ > > > > Beginners mailing list > > > > Beginners at haskell.org > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From agander at gmail.com Tue Dec 12 14:04:36 2017 From: agander at gmail.com (agander) Date: Tue, 12 Dec 2017 15:04:36 +0100 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212153830.7425ca8f@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212131850.eaqdnm6jopreeall@x60s.casa> <20171212153830.7425ca8f@Pavel> Message-ID: I put: compiler: ghc-8.2.1 in the stack.yaml of my project which picks up the right version. This didnt work prior to my current stack version 1.6.1 Giles On 12 December 2017 at 14:38, Baa wrote: > 1. GHC 8.2.2 is here: > ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.2/bin > 2. done > 3. yes, it's 8.2.2 > 4. `cabal new-build` said to me call `cabal update`, I done it, then run > it again and got: > $ cabal new-build > Resolving dependencies... > cabal: Could not resolve dependencies: > trying: XXX-0.5.0.0 (user goal) > next goal: YYY-utils (dependency of XXX-0.5.0.0) > Dependency tree exhaustively searched. > > > On Tue, Dec 12, 2017 at 02:53:47PM +0200, Baa wrote: > > > @Francesco: unfortunately nightly misses some package. So, I tried: > > > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > > Preparing to install GHC (tinfo6) to an isolated location. This > > > will not interfere with any system-level installation. Already > > > downloaded. Installed GHC. > > > > > > stack will use a sandboxed GHC it installed > > > For more information on paths, see 'stack path' and 'stack exec > > > env' To use this GHC and packages outside of a project, consider > > > using: stack ghc, stack ghci, stack runghc, or stack exec > > > > > > So seems that 8.2.2 was installed, right? But how to build the > > > project with new GHC now? I never used cabal before, `stack ghci` > > > still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 does not > > > correspond to .yaml file LTS - maybe this is a reason why old 8.0.2 > > > is stil used... > > > > > > When I try cabal build/new-build/repl I get: > > > > > > cabal: The program 'ghc' version >=6.4 is required but it could > > > not be found. > > > > > > So, cabal does not know about installed GHC versions (at least > > > 8.0.2, used by stack). I tried --require-sandbox but without > > > success. > > > > Hey Paul, > > four-step plan: > > > > 1. check where stack installed ghc, it should be something like: > > > > ~/.stack/programs/x86_32-linux/ghc-nopie-8.2.1/lib/ghc-8.2.1/bin > > > > 2. add these two lines to your `~/.bashrc`: > > > > export PATH=~/.cabal/bin:$PATH # path to stuff built with cabal > > export PATH=~/the.stackpathabove:$PATH # path to ghc > > > > 3. check the right ghc version has been selected: > > > > ghc -v > > # should be 8.2.2 > > > > 4. cd into your project and `cabal new-build` and then open a repl on > > it with `cabal new-repl`. > > > > Let us know if this works! > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Tue Dec 12 14:06:44 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 16:06:44 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212135118.bk24obonpzb7wfen@x60s.casa> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212131850.eaqdnm6jopreeall@x60s.casa> <20171212153830.7425ca8f@Pavel> <20171212135118.bk24obonpzb7wfen@x60s.casa> Message-ID: <20171212160644.3dcf327e@Pavel> I done it, but got the same error. My project uses several my packages (libraries), they are called 'my-*'. I changed in their .cabal-files versions range of "base" too, but error is the same. Build-depends stanza of executable looks like: build-depends: base >= 4.9 && < 4.11 , text , my-common-utils , my-atlassian-utils , my-jenkins-utils , my-git-utils , aeson , network-uri , network-info , text-show , hslogger , bytestring , transformers , aeson-pretty , time , email-validate , streaming , containers , sqlite-simple , directory , tuple , async , mime-mail , HaskellNet , HaskellNet-SSL , mustache , path , exceptions , mono-traversable , data-default-class , path-io , split , microlens , microlens-th , regex-pcre , pcre-utils , unordered-containers , formatting > On Tue, Dec 12, 2017 at 03:38:30PM +0200, Baa wrote: > > 1. GHC 8.2.2 is here: > > ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.2/bin > > 2. done > > 3. yes, it's 8.2.2 > > 4. `cabal new-build` said to me call `cabal update`, I done it, > > then run it again and got: > > $ cabal new-build > > Resolving dependencies... > > cabal: Could not resolve dependencies: > > trying: XXX-0.5.0.0 (user goal) > > next goal: YYY-utils (dependency of XXX-0.5.0.0) > > Dependency tree exhaustively searched. > > Good, we're almost there! > > I strongly suspect it is a base constraint. Go in your something.cabal > file, build-depends section(s) and modify it from: > > base >= 4.somenumber && < 4.10 > > to > > base >= 4.somenumber && < 4.11 > > And try cabal new-build again. If that fails, please include the > content of your `build-depends:` portion in your message > -F > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From toad3k at gmail.com Tue Dec 12 14:20:32 2017 From: toad3k at gmail.com (David McBride) Date: Tue, 12 Dec 2017 09:20:32 -0500 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212160644.3dcf327e@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212131850.eaqdnm6jopreeall@x60s.casa> <20171212153830.7425ca8f@Pavel> <20171212135118.bk24obonpzb7wfen@x60s.casa> <20171212160644.3dcf327e@Pavel> Message-ID: If your original goal was to test for a ghc panic in newer ghc, my final suggestion would be to get a minimal example that panics without all these extra dependencies. If you happen to find that the bug exists in newer ghc, you'd have to do that anyways to submit a useful bug report. On Tue, Dec 12, 2017 at 9:06 AM, Baa wrote: > I done it, but got the same error. My project uses several my packages > (libraries), they are called 'my-*'. I changed in their .cabal-files > versions range of "base" too, but error is the same. Build-depends > stanza of executable looks like: > > build-depends: base >= 4.9 && < 4.11 > , text > , my-common-utils > , my-atlassian-utils > , my-jenkins-utils > , my-git-utils > , aeson > , network-uri > , network-info > , text-show > , hslogger > , bytestring > , transformers > , aeson-pretty > , time > , email-validate > , streaming > , containers > , sqlite-simple > , directory > , tuple > , async > , mime-mail > , HaskellNet > , HaskellNet-SSL > , mustache > , path > , exceptions > , mono-traversable > , data-default-class > , path-io > , split > , microlens > , microlens-th > , regex-pcre > , pcre-utils > , unordered-containers > , formatting > > > > On Tue, Dec 12, 2017 at 03:38:30PM +0200, Baa wrote: > > > 1. GHC 8.2.2 is here: > > > ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.2/bin > > > 2. done > > > 3. yes, it's 8.2.2 > > > 4. `cabal new-build` said to me call `cabal update`, I done it, > > > then run it again and got: > > > $ cabal new-build > > > Resolving dependencies... > > > cabal: Could not resolve dependencies: > > > trying: XXX-0.5.0.0 (user goal) > > > next goal: YYY-utils (dependency of XXX-0.5.0.0) > > > Dependency tree exhaustively searched. > > > > Good, we're almost there! > > > > I strongly suspect it is a base constraint. Go in your something.cabal > > file, build-depends section(s) and modify it from: > > > > base >= 4.somenumber && < 4.10 > > > > to > > > > base >= 4.somenumber && < 4.11 > > > > And try cabal new-build again. If that fails, please include the > > content of your `build-depends:` portion in your message > > -F > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Tue Dec 12 14:21:19 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 12 Dec 2017 15:21:19 +0100 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212160644.3dcf327e@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212131850.eaqdnm6jopreeall@x60s.casa> <20171212153830.7425ca8f@Pavel> <20171212135118.bk24obonpzb7wfen@x60s.casa> <20171212160644.3dcf327e@Pavel> Message-ID: <20171212142119.3povve3ygsuq2sci@x60s.casa> On Tue, Dec 12, 2017 at 04:06:44PM +0200, Baa wrote: > I done it, but got the same error. My project uses several my packages > (libraries), they are called 'my-*'. I changed in their .cabal-files > versions range of "base" too, but error is the same. Build-depends > stanza of executable looks like: > > [...] Ok, most likey some package maintainer hasn't update their boundaries to work with 8.2.2. Go with cabal new-build --allow-newer and maybe politely nudge maintainers to relax their dep.bounds appropriately -F From aquagnu at gmail.com Tue Dec 12 14:33:13 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 16:33:13 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212154345.083ddfa0@Pavel> Message-ID: <20171212163313.65b37337@Pavel> @Michael Snoyman: I returned back all .cabal-files and added compiler: ghc-8.2.2, `stack build` printed out this: ---cut--- Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for Cabal-1.24.2.0: process-1.6.1.0 from stack configuration does not match >=1.1.0.1 && <1.5 (latest matching version is 1.4.3.0) needed due to my-common-utils-0.2.0.0 -> Cabal-1.24.2.0 In the dependencies for versions-3.1.1: base-4.10.1.0 from stack configuration does not match >=4.8 && <4.10 (latest matching version is 4.9.1.0) needed due to my-common-utils-0.2.0.0 -> versions-3.1.1 Some potential ways to resolve this: * Recommended action: try adding the following to your extra-deps in /home/pavel/prj/automation/revcompl-mon/stack.yaml: - base-4.9.1.0 - process-1.4.3.0 * Set 'allow-newer: true' to ignore all version constraints and build anyway. * You may also want to try using the 'stack solver' command. Plan construction failed. ---cut--- After adding "allow-newer: true" build process starts, all looked fine until: .../SimpleTagging.hs:281:51: error: • Couldn't match type ‘Type’ with ‘DerivClause’ Expected type: [DerivClause] Actual type: [Type] • In the sixth argument of ‘DataD’, namely ‘derivs'’ In the expression: DataD [] ty' tyVars Nothing newCs derivs' In the first argument of ‘(++)’, namely ‘[DataD [] ty' tyVars Nothing newCs derivs']’ | 281 | return $ [DataD [] ty' tyVars Nothing newCs derivs'] ++ showInst | ^^^^^^^ which IMHO means that TemplateHaskell ("API") was changed from 8.0.2 to 8.2.2 because the same code is compiling with old GHC 8.0.2. > Hi Paul, > > A Stackage snapshot specifies both a GHC version and a set of > packages. Stackage snapshots are built and tested to ensure that the > packages are compatible. While you could tell Stack to use a > different GHC version with a snapshot[1], this is unlikely to work, > since GHC major releases usually break some packages. > > I think everyone who's trying to help you (both with Cabal and Stack > workflows) would be able to do so better if you explain which package > you're trying to use which is no longer available in Stackage > Nightly. In some cases, you can simply add it as an extra > dependencies for Stack (e.g., `extra-deps: [acme-missiles-0.3]`), > while in others there is some inherent incompatibility. > > Right now, you'll just be getting guesses about how to theoretically > get some unknown package to build with a bunch of others. > > Michael > > [1] Using a setting like `compiler: ghc-8.2.2` > > On Tue, Dec 12, 2017 at 3:43 PM, Baa wrote: > > > @David: I tried to switch to nightly but in project's .yaml file and > > got error about missing of some library (as I understand, it is > > missing in last nightly). So, if I try to do it through .yaml file > > then how to use new GHC (8.2.2) but with LTS for 8.0.2? Is it > > possible? I need last stable LTS where all libraries (using in the > > projects) exist, but with new GHC 8.2.2 which is too new for stable > > LTS. As I read somewhere, GHC version and Stackage version are > > linked together hardly in stack tool, or? > > > > > You can see how to configure stack here: > > > https://github.com/commercialhaskell/stack/blob/release/doc/yaml_ > > configuration.md > > > > > > The short of it is that to have stack ghci choose a particular > > > version of ghc, you probably need to modify > > > ~/.stack/global/stack.yaml, change resolver to something here > > > https://www.stackage.org/snapshots that has your version of ghc > > > and dependencies similar to what your project wants. For example > > > 'nightly-2017-12-10'. > > > > > > On Tue, Dec 12, 2017 at 7:53 AM, Baa wrote: > > > > > > > @Francesco: unfortunately nightly misses some package. So, I > > > > tried: > > > > > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > > > Preparing to install GHC (tinfo6) to an isolated location. > > > > This will not interfere with any system-level installation. > > > > Already downloaded. Installed GHC. > > > > > > > > stack will use a sandboxed GHC it installed > > > > For more information on paths, see 'stack path' and 'stack > > > > exec env' To use this GHC and packages outside of a project, > > > > consider using: stack ghc, stack ghci, stack runghc, or stack > > > > exec > > > > > > > > So seems that 8.2.2 was installed, right? But how to build the > > > > project with new GHC now? I never used cabal before, `stack > > > > ghci` still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 > > > > does not correspond to .yaml file LTS - maybe this is a reason > > > > why old 8.0.2 is stil used... > > > > > > > > When I try cabal build/new-build/repl I get: > > > > > > > > cabal: The program 'ghc' version >=6.4 is required but it > > > > could not be found. > > > > > > > > So, cabal does not know about installed GHC versions (at least > > > > 8.0.2, used by stack). I tried --require-sandbox but without > > > > success. > > > > > > > > > > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > > > > Would somebody explain me what is wrong here and how I can > > > > > > test a project with new 8.2.2 GHC? > > > > > > > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a > > > > > nightly or download/install ghc from here and compile your > > > > > project with the new `cabal new-build`. > > > > > > > > > > [1] > > > > > https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > > > > > > > > > > _______________________________________________ > > > > > Beginners mailing list > > > > > Beginners at haskell.org > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > _______________________________________________ > > > > Beginners mailing list > > > > Beginners at haskell.org > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From aquagnu at gmail.com Tue Dec 12 14:48:31 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 16:48:31 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212131850.eaqdnm6jopreeall@x60s.casa> <20171212153830.7425ca8f@Pavel> <20171212135118.bk24obonpzb7wfen@x60s.casa> <20171212160644.3dcf327e@Pavel> Message-ID: <20171212164831.42cc92bb@Pavel> @Francesco: seems that code which I tried to test with new compiler is out-of-date for it's Template Haskell "API". @David: I planned to check existing code with new compiler (to be sure that my code is OK), but seems that it needs to re-wrire the code, so I will comment problematic test, GHC bug happens only is the test and not in usual application code. @all: Thanks a lot for all tips and help!! PS. IMHO seems that Template Haskell gives more problems then solves them :) === Best regards, Paul > If your original goal was to test for a ghc panic in newer ghc, my > final suggestion would be to get a minimal example that panics > without all these extra dependencies. If you happen to find that the > bug exists in newer ghc, you'd have to do that anyways to submit a > useful bug report. > > On Tue, Dec 12, 2017 at 9:06 AM, Baa wrote: > > > I done it, but got the same error. My project uses several my > > packages (libraries), they are called 'my-*'. I changed in > > their .cabal-files versions range of "base" too, but error is the > > same. Build-depends stanza of executable looks like: > > > > build-depends: base >= 4.9 && < 4.11 > > , text > > , my-common-utils > > , my-atlassian-utils > > , my-jenkins-utils > > , my-git-utils > > , aeson > > , network-uri > > , network-info > > , text-show > > , hslogger > > , bytestring > > , transformers > > , aeson-pretty > > , time > > , email-validate > > , streaming > > , containers > > , sqlite-simple > > , directory > > , tuple > > , async > > , mime-mail > > , HaskellNet > > , HaskellNet-SSL > > , mustache > > , path > > , exceptions > > , mono-traversable > > , data-default-class > > , path-io > > , split > > , microlens > > , microlens-th > > , regex-pcre > > , pcre-utils > > , unordered-containers > > , formatting > > > > > > > On Tue, Dec 12, 2017 at 03:38:30PM +0200, Baa wrote: > > > > 1. GHC 8.2.2 is here: > > > > ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.2/bin > > > > 2. done > > > > 3. yes, it's 8.2.2 > > > > 4. `cabal new-build` said to me call `cabal update`, I done it, > > > > then run it again and got: > > > > $ cabal new-build > > > > Resolving dependencies... > > > > cabal: Could not resolve dependencies: > > > > trying: XXX-0.5.0.0 (user goal) > > > > next goal: YYY-utils (dependency of XXX-0.5.0.0) > > > > Dependency tree exhaustively searched. > > > > > > Good, we're almost there! > > > > > > I strongly suspect it is a base constraint. Go in your > > > something.cabal file, build-depends section(s) and modify it from: > > > > > > base >= 4.somenumber && < 4.10 > > > > > > to > > > > > > base >= 4.somenumber && < 4.11 > > > > > > And try cabal new-build again. If that fails, please include the > > > content of your `build-depends:` portion in your message > > > -F > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From michael at snoyman.com Tue Dec 12 14:50:18 2017 From: michael at snoyman.com (Michael Snoyman) Date: Tue, 12 Dec 2017 14:50:18 +0000 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212163313.65b37337@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212154345.083ddfa0@Pavel> <20171212163313.65b37337@Pavel> Message-ID: That's right, the template-haskell API frequently changes between major releases of GHC. On Tue, Dec 12, 2017, 4:35 PM Baa wrote: > @Michael Snoyman: > > I returned back all .cabal-files and added compiler: ghc-8.2.2, `stack > build` > printed out this: > > ---cut--- > Error: While constructing the build plan, the following exceptions were > encountered: > > In the dependencies for Cabal-1.24.2.0: > process-1.6.1.0 from stack configuration does not match >=1.1.0.1 && > <1.5 (latest matching version is 1.4.3.0) > needed due to my-common-utils-0.2.0.0 -> Cabal-1.24.2.0 > > In the dependencies for versions-3.1.1: > base-4.10.1.0 from stack configuration does not match >=4.8 && <4.10 > (latest matching version is 4.9.1.0) > needed due to my-common-utils-0.2.0.0 -> versions-3.1.1 > > Some potential ways to resolve this: > > * Recommended action: try adding the following to your extra-deps in > /home/pavel/prj/automation/revcompl-mon/stack.yaml: > > - base-4.9.1.0 > - process-1.4.3.0 > > * Set 'allow-newer: true' to ignore all version constraints and build > anyway. > > * You may also want to try using the 'stack solver' command. > > Plan construction failed. > ---cut--- > > After adding "allow-newer: true" build process starts, all looked fine > until: > > .../SimpleTagging.hs:281:51: error: > • Couldn't match type ‘Type’ with ‘DerivClause’ > Expected type: [DerivClause] > Actual type: [Type] > • In the sixth argument of ‘DataD’, namely ‘derivs'’ > In the expression: DataD [] ty' tyVars Nothing newCs derivs' > In the first argument of ‘(++)’, namely > ‘[DataD [] ty' tyVars Nothing newCs derivs']’ > | > 281 | return $ [DataD [] ty' tyVars Nothing newCs derivs'] ++ > showInst > | ^^^^^^^ > > which IMHO means that TemplateHaskell ("API") was changed from 8.0.2 to > 8.2.2 because the same code is compiling with old GHC 8.0.2. > > > > Hi Paul, > > > > A Stackage snapshot specifies both a GHC version and a set of > > packages. Stackage snapshots are built and tested to ensure that the > > packages are compatible. While you could tell Stack to use a > > different GHC version with a snapshot[1], this is unlikely to work, > > since GHC major releases usually break some packages. > > > > I think everyone who's trying to help you (both with Cabal and Stack > > workflows) would be able to do so better if you explain which package > > you're trying to use which is no longer available in Stackage > > Nightly. In some cases, you can simply add it as an extra > > dependencies for Stack (e.g., `extra-deps: [acme-missiles-0.3]`), > > while in others there is some inherent incompatibility. > > > > Right now, you'll just be getting guesses about how to theoretically > > get some unknown package to build with a bunch of others. > > > > Michael > > > > [1] Using a setting like `compiler: ghc-8.2.2` > > > > On Tue, Dec 12, 2017 at 3:43 PM, Baa wrote: > > > > > @David: I tried to switch to nightly but in project's .yaml file and > > > got error about missing of some library (as I understand, it is > > > missing in last nightly). So, if I try to do it through .yaml file > > > then how to use new GHC (8.2.2) but with LTS for 8.0.2? Is it > > > possible? I need last stable LTS where all libraries (using in the > > > projects) exist, but with new GHC 8.2.2 which is too new for stable > > > LTS. As I read somewhere, GHC version and Stackage version are > > > linked together hardly in stack tool, or? > > > > > > > You can see how to configure stack here: > > > > https://github.com/commercialhaskell/stack/blob/release/doc/yaml_ > > > configuration.md > > > > > > > > The short of it is that to have stack ghci choose a particular > > > > version of ghc, you probably need to modify > > > > ~/.stack/global/stack.yaml, change resolver to something here > > > > https://www.stackage.org/snapshots that has your version of ghc > > > > and dependencies similar to what your project wants. For example > > > > 'nightly-2017-12-10'. > > > > > > > > On Tue, Dec 12, 2017 at 7:53 AM, Baa wrote: > > > > > > > > > @Francesco: unfortunately nightly misses some package. So, I > > > > > tried: > > > > > > > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > > > > Preparing to install GHC (tinfo6) to an isolated location. > > > > > This will not interfere with any system-level installation. > > > > > Already downloaded. Installed GHC. > > > > > > > > > > stack will use a sandboxed GHC it installed > > > > > For more information on paths, see 'stack path' and 'stack > > > > > exec env' To use this GHC and packages outside of a project, > > > > > consider using: stack ghc, stack ghci, stack runghc, or stack > > > > > exec > > > > > > > > > > So seems that 8.2.2 was installed, right? But how to build the > > > > > project with new GHC now? I never used cabal before, `stack > > > > > ghci` still runs 8.0.2 instead of 8.2.2. Installed GHC 8.2.2 > > > > > does not correspond to .yaml file LTS - maybe this is a reason > > > > > why old 8.0.2 is stil used... > > > > > > > > > > When I try cabal build/new-build/repl I get: > > > > > > > > > > cabal: The program 'ghc' version >=6.4 is required but it > > > > > could not be found. > > > > > > > > > > So, cabal does not know about installed GHC versions (at least > > > > > 8.0.2, used by stack). I tried --require-sandbox but without > > > > > success. > > > > > > > > > > > > > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > > > > > Would somebody explain me what is wrong here and how I can > > > > > > > test a project with new 8.2.2 GHC? > > > > > > > > > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. Use a > > > > > > nightly or download/install ghc from here and compile your > > > > > > project with the new `cabal new-build`. > > > > > > > > > > > > [1] > > > > > > https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > Beginners mailing list > > > > > > Beginners at haskell.org > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > _______________________________________________ > > > > > Beginners mailing list > > > > > Beginners at haskell.org > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Tue Dec 12 15:25:34 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 17:25:34 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212154345.083ddfa0@Pavel> <20171212163313.65b37337@Pavel> Message-ID: <20171212172534.6558b2ee@Pavel> @Michael, so my newbie's questions: - how Haskellers proceed in this case? Rewrites Template Haskells code after every switch to new versions? Or it's not common practice to switch projects from one GHC version to another? What about LTS? Do you switch to new one often? Is there a practice to keep project on one LTS/GHC versions and never to update them (I mean common, good known, convenient practice in Haskell)? For example, no problem to use out-of-date libraries in C/C++, in embedded development, etc, but what about Haskell? IMHO it's better to update due to bug fixing, new features, but it's interesting common practice in Haskell projects. === Best regards, Paul > That's right, the template-haskell API frequently changes between > major releases of GHC. > > On Tue, Dec 12, 2017, 4:35 PM Baa wrote: > > > @Michael Snoyman: > > > > I returned back all .cabal-files and added compiler: ghc-8.2.2, > > `stack build` > > printed out this: > > > > ---cut--- > > Error: While constructing the build plan, the following > > exceptions were encountered: > > > > In the dependencies for Cabal-1.24.2.0: > > process-1.6.1.0 from stack configuration does not match > > >=1.1.0.1 && <1.5 (latest matching version is 1.4.3.0) > > needed due to my-common-utils-0.2.0.0 -> Cabal-1.24.2.0 > > > > In the dependencies for versions-3.1.1: > > base-4.10.1.0 from stack configuration does not match >=4.8 > > && <4.10 (latest matching version is 4.9.1.0) > > needed due to my-common-utils-0.2.0.0 -> versions-3.1.1 > > > > Some potential ways to resolve this: > > > > * Recommended action: try adding the following to your > > extra-deps in /home/pavel/prj/automation/revcompl-mon/stack.yaml: > > > > - base-4.9.1.0 > > - process-1.4.3.0 > > > > * Set 'allow-newer: true' to ignore all version constraints and > > build anyway. > > > > * You may also want to try using the 'stack solver' command. > > > > Plan construction failed. > > ---cut--- > > > > After adding "allow-newer: true" build process starts, all looked > > fine until: > > > > .../SimpleTagging.hs:281:51: error: > > • Couldn't match type ‘Type’ with ‘DerivClause’ > > Expected type: [DerivClause] > > Actual type: [Type] > > • In the sixth argument of ‘DataD’, namely ‘derivs'’ > > In the expression: DataD [] ty' tyVars Nothing newCs > > derivs' In the first argument of ‘(++)’, namely > > ‘[DataD [] ty' tyVars Nothing newCs derivs']’ > > | > > 281 | return $ [DataD [] ty' tyVars Nothing newCs > > derivs'] ++ showInst > > | ^^^^^^^ > > > > which IMHO means that TemplateHaskell ("API") was changed from > > 8.0.2 to 8.2.2 because the same code is compiling with old GHC > > 8.0.2. > > > > > > > Hi Paul, > > > > > > A Stackage snapshot specifies both a GHC version and a set of > > > packages. Stackage snapshots are built and tested to ensure that > > > the packages are compatible. While you could tell Stack to use a > > > different GHC version with a snapshot[1], this is unlikely to > > > work, since GHC major releases usually break some packages. > > > > > > I think everyone who's trying to help you (both with Cabal and > > > Stack workflows) would be able to do so better if you explain > > > which package you're trying to use which is no longer available > > > in Stackage Nightly. In some cases, you can simply add it as an > > > extra dependencies for Stack (e.g., `extra-deps: > > > [acme-missiles-0.3]`), while in others there is some inherent > > > incompatibility. > > > > > > Right now, you'll just be getting guesses about how to > > > theoretically get some unknown package to build with a bunch of > > > others. > > > > > > Michael > > > > > > [1] Using a setting like `compiler: ghc-8.2.2` > > > > > > On Tue, Dec 12, 2017 at 3:43 PM, Baa wrote: > > > > > > > @David: I tried to switch to nightly but in project's .yaml > > > > file and got error about missing of some library (as I > > > > understand, it is missing in last nightly). So, if I try to do > > > > it through .yaml file then how to use new GHC (8.2.2) but with > > > > LTS for 8.0.2? Is it possible? I need last stable LTS where all > > > > libraries (using in the projects) exist, but with new GHC 8.2.2 > > > > which is too new for stable LTS. As I read somewhere, GHC > > > > version and Stackage version are linked together hardly in > > > > stack tool, or? > > > > > You can see how to configure stack here: > > > > > https://github.com/commercialhaskell/stack/blob/release/doc/yaml_ > > > > configuration.md > > > > > > > > > > The short of it is that to have stack ghci choose a particular > > > > > version of ghc, you probably need to modify > > > > > ~/.stack/global/stack.yaml, change resolver to something here > > > > > https://www.stackage.org/snapshots that has your version of > > > > > ghc and dependencies similar to what your project wants. For > > > > > example 'nightly-2017-12-10'. > > > > > > > > > > On Tue, Dec 12, 2017 at 7:53 AM, Baa > > > > > wrote: > > > > > > @Francesco: unfortunately nightly misses some package. So, I > > > > > > tried: > > > > > > > > > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > > > > > Preparing to install GHC (tinfo6) to an isolated location. > > > > > > This will not interfere with any system-level installation. > > > > > > Already downloaded. Installed GHC. > > > > > > > > > > > > stack will use a sandboxed GHC it installed > > > > > > For more information on paths, see 'stack path' and 'stack > > > > > > exec env' To use this GHC and packages outside of a project, > > > > > > consider using: stack ghc, stack ghci, stack runghc, or > > > > > > stack exec > > > > > > > > > > > > So seems that 8.2.2 was installed, right? But how to build > > > > > > the project with new GHC now? I never used cabal before, > > > > > > `stack ghci` still runs 8.0.2 instead of 8.2.2. Installed > > > > > > GHC 8.2.2 does not correspond to .yaml file LTS - maybe > > > > > > this is a reason why old 8.0.2 is stil used... > > > > > > > > > > > > When I try cabal build/new-build/repl I get: > > > > > > > > > > > > cabal: The program 'ghc' version >=6.4 is required but it > > > > > > could not be found. > > > > > > > > > > > > So, cabal does not know about installed GHC versions (at > > > > > > least 8.0.2, used by stack). I tried --require-sandbox but > > > > > > without success. > > > > > > > > > > > > > > > > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > > > > > > Would somebody explain me what is wrong here and how I > > > > > > > > can test a project with new 8.2.2 GHC? > > > > > > > > > > > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. > > > > > > > Use a nightly or download/install ghc from here and > > > > > > > compile your project with the new `cabal new-build`. > > > > > > > > > > > > > > [1] > > > > > > > https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Beginners mailing list > > > > > > > Beginners at haskell.org > > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > _______________________________________________ > > > > > > Beginners mailing list > > > > > > Beginners at haskell.org > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > > > _______________________________________________ > > > > Beginners mailing list > > > > Beginners at haskell.org > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From michael at snoyman.com Tue Dec 12 15:46:44 2017 From: michael at snoyman.com (Michael Snoyman) Date: Tue, 12 Dec 2017 17:46:44 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212172534.6558b2ee@Pavel> References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212154345.083ddfa0@Pavel> <20171212163313.65b37337@Pavel> <20171212172534.6558b2ee@Pavel> Message-ID: IMO, there are two different cases you need to care about: 1. If you're writing an application, keeping broad support for lots of compiler and library versions isn't vital. You can dictate exactly which versions of dependencies your application is compiled with. I use this for web applications I write and command line tools (including Stack), for example. In this case: pick an LTS snapshot, add extra-deps on demand if absolutely necessary, and then when you see a strong need (like upstream bug fixes), update your stack.yaml to a newer snapshot to get new GHC and library versions. 2. If you're writing a library that you expect others to be using, keep as broad a support base as possible. This is encouraged by things like the complex Travis config in the Stack docs[1], which build with many different LTS snapshots, as well as using many versions of GHC and cabal-install (to cover the dep solver case). This allows consumers of your library to more easily mix and match which versions of dependencies they want to put together. When there is an upstream breaking change, it's tempting to just drop support for the old version, add a lower bound in your cabal file to say "I no longer support the old version," and move on. But IMO a nicer solution for your users is to introduce conditional compilation, e.g.: #if MIN_VERSION_transformers(0, 5, 0) -- use transformers 0.5 or later #else -- use transformers 0.4 or earlier #endif This definitely adds extra burden to you as a writer, but it helps others significantly. This is also strong motivation to try to avoid breaking backwards compatibility in your APIs, as every such breakage can cause a cascade of downstream pain[2]. I hope that answers your questions, let me know if you want me to clarify any points here. [1] https://github.com/commercialhaskell/stack/blob/master/doc/travis-complex.yml [2] In case anyone's wondering: this has nothing to do with bounds in your cabal file, I'm talking about actual code breakage On Tue, Dec 12, 2017 at 5:25 PM, Baa wrote: > @Michael, so my newbie's questions: > > - how Haskellers proceed in this case? Rewrites Template Haskells code > after every switch to new versions? Or it's not common practice to > switch projects from one GHC version to another? What about LTS? Do > you switch to new one often? Is there a practice to keep project on > one LTS/GHC versions and never to update them (I mean common, good > known, convenient practice in Haskell)? For example, no problem to > use out-of-date libraries in C/C++, in embedded development, etc, but > what about Haskell? > > IMHO it's better to update due to bug fixing, new features, but it's > interesting common practice in Haskell projects. > > === > Best regards, Paul > > > That's right, the template-haskell API frequently changes between > > major releases of GHC. > > > > On Tue, Dec 12, 2017, 4:35 PM Baa wrote: > > > > > @Michael Snoyman: > > > > > > I returned back all .cabal-files and added compiler: ghc-8.2.2, > > > `stack build` > > > printed out this: > > > > > > ---cut--- > > > Error: While constructing the build plan, the following > > > exceptions were encountered: > > > > > > In the dependencies for Cabal-1.24.2.0: > > > process-1.6.1.0 from stack configuration does not match > > > >=1.1.0.1 && <1.5 (latest matching version is 1.4.3.0) > > > needed due to my-common-utils-0.2.0.0 -> Cabal-1.24.2.0 > > > > > > In the dependencies for versions-3.1.1: > > > base-4.10.1.0 from stack configuration does not match >=4.8 > > > && <4.10 (latest matching version is 4.9.1.0) > > > needed due to my-common-utils-0.2.0.0 -> versions-3.1.1 > > > > > > Some potential ways to resolve this: > > > > > > * Recommended action: try adding the following to your > > > extra-deps in /home/pavel/prj/automation/revcompl-mon/stack.yaml: > > > > > > - base-4.9.1.0 > > > - process-1.4.3.0 > > > > > > * Set 'allow-newer: true' to ignore all version constraints and > > > build anyway. > > > > > > * You may also want to try using the 'stack solver' command. > > > > > > Plan construction failed. > > > ---cut--- > > > > > > After adding "allow-newer: true" build process starts, all looked > > > fine until: > > > > > > .../SimpleTagging.hs:281:51: error: > > > • Couldn't match type ‘Type’ with ‘DerivClause’ > > > Expected type: [DerivClause] > > > Actual type: [Type] > > > • In the sixth argument of ‘DataD’, namely ‘derivs'’ > > > In the expression: DataD [] ty' tyVars Nothing newCs > > > derivs' In the first argument of ‘(++)’, namely > > > ‘[DataD [] ty' tyVars Nothing newCs derivs']’ > > > | > > > 281 | return $ [DataD [] ty' tyVars Nothing newCs > > > derivs'] ++ showInst > > > | ^^^^^^^ > > > > > > which IMHO means that TemplateHaskell ("API") was changed from > > > 8.0.2 to 8.2.2 because the same code is compiling with old GHC > > > 8.0.2. > > > > > > > > > > Hi Paul, > > > > > > > > A Stackage snapshot specifies both a GHC version and a set of > > > > packages. Stackage snapshots are built and tested to ensure that > > > > the packages are compatible. While you could tell Stack to use a > > > > different GHC version with a snapshot[1], this is unlikely to > > > > work, since GHC major releases usually break some packages. > > > > > > > > I think everyone who's trying to help you (both with Cabal and > > > > Stack workflows) would be able to do so better if you explain > > > > which package you're trying to use which is no longer available > > > > in Stackage Nightly. In some cases, you can simply add it as an > > > > extra dependencies for Stack (e.g., `extra-deps: > > > > [acme-missiles-0.3]`), while in others there is some inherent > > > > incompatibility. > > > > > > > > Right now, you'll just be getting guesses about how to > > > > theoretically get some unknown package to build with a bunch of > > > > others. > > > > > > > > Michael > > > > > > > > [1] Using a setting like `compiler: ghc-8.2.2` > > > > > > > > On Tue, Dec 12, 2017 at 3:43 PM, Baa wrote: > > > > > > > > > @David: I tried to switch to nightly but in project's .yaml > > > > > file and got error about missing of some library (as I > > > > > understand, it is missing in last nightly). So, if I try to do > > > > > it through .yaml file then how to use new GHC (8.2.2) but with > > > > > LTS for 8.0.2? Is it possible? I need last stable LTS where all > > > > > libraries (using in the projects) exist, but with new GHC 8.2.2 > > > > > which is too new for stable LTS. As I read somewhere, GHC > > > > > version and Stackage version are linked together hardly in > > > > > stack tool, or? > > > > > > You can see how to configure stack here: > > > > > > https://github.com/commercialhaskell/stack/blob/ > release/doc/yaml_ > > > > > configuration.md > > > > > > > > > > > > The short of it is that to have stack ghci choose a particular > > > > > > version of ghc, you probably need to modify > > > > > > ~/.stack/global/stack.yaml, change resolver to something here > > > > > > https://www.stackage.org/snapshots that has your version of > > > > > > ghc and dependencies similar to what your project wants. For > > > > > > example 'nightly-2017-12-10'. > > > > > > > > > > > > On Tue, Dec 12, 2017 at 7:53 AM, Baa > > > > > > wrote: > > > > > > > @Francesco: unfortunately nightly misses some package. So, I > > > > > > > tried: > > > > > > > > > > > > > > $ stack --resolver=ghc-8.2.2 setup --reinstall > > > > > > > Preparing to install GHC (tinfo6) to an isolated location. > > > > > > > This will not interfere with any system-level installation. > > > > > > > Already downloaded. Installed GHC. > > > > > > > > > > > > > > stack will use a sandboxed GHC it installed > > > > > > > For more information on paths, see 'stack path' and 'stack > > > > > > > exec env' To use this GHC and packages outside of a project, > > > > > > > consider using: stack ghc, stack ghci, stack runghc, or > > > > > > > stack exec > > > > > > > > > > > > > > So seems that 8.2.2 was installed, right? But how to build > > > > > > > the project with new GHC now? I never used cabal before, > > > > > > > `stack ghci` still runs 8.0.2 instead of 8.2.2. Installed > > > > > > > GHC 8.2.2 does not correspond to .yaml file LTS - maybe > > > > > > > this is a reason why old 8.0.2 is stil used... > > > > > > > > > > > > > > When I try cabal build/new-build/repl I get: > > > > > > > > > > > > > > cabal: The program 'ghc' version >=6.4 is required but it > > > > > > > could not be found. > > > > > > > > > > > > > > So, cabal does not know about installed GHC versions (at > > > > > > > least 8.0.2, used by stack). I tried --require-sandbox but > > > > > > > without success. > > > > > > > > > > > > > > > > > > > > > > On Tue, Dec 12, 2017 at 01:56:03PM +0200, Baa wrote: > > > > > > > > > Would somebody explain me what is wrong here and how I > > > > > > > > > can test a project with new 8.2.2 GHC? > > > > > > > > > > > > > > > > Hello Paul, I don't think stack lts has 8.2.2 just yet. > > > > > > > > Use a nightly or download/install ghc from here and > > > > > > > > compile your project with the new `cabal new-build`. > > > > > > > > > > > > > > > > [1] > > > > > > > > https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > Beginners mailing list > > > > > > > > Beginners at haskell.org > > > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Beginners mailing list > > > > > > > Beginners at haskell.org > > > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > Beginners mailing list > > > > > Beginners at haskell.org > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners at haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Tue Dec 12 16:26:43 2017 From: aquagnu at gmail.com (Baa) Date: Tue, 12 Dec 2017 18:26:43 +0200 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: References: <20171212135603.61ee055f@Pavel> <20171212120915.6epux6bhnx4gbn62@x60s.casa> <20171212145347.5e211ff2@Pavel> <20171212154345.083ddfa0@Pavel> <20171212163313.65b37337@Pavel> <20171212172534.6558b2ee@Pavel> Message-ID: <20171212182644.23ad578a@Pavel> @Michael Snoyman: thank you a lot! Yes, absolutely makes sense. === Best regards, Paul From vale.cofershabica at gmail.com Tue Dec 12 18:41:51 2017 From: vale.cofershabica at gmail.com (Vale Cofer-Shabica) Date: Tue, 12 Dec 2017 13:41:51 -0500 Subject: [Haskell-beginners] IO question Message-ID: Just to add to David's answer, when I find myself in situations like: foo >>= return . bar hlint helpfully suggests: fmap bar foo So you could also have: fmap (splitOn ",") $ readFile "data.txt" -vale -- vale cofer-shabica 401.267.8253 On Mon, Dec 11, 2017 at 4:24 PM, mike h wrote: > Thank you David. Before posting I tried readFile "data.txt" >>= … but got > errors as I didn’t use return.!! > > Mike > > > > On 11 Dec 2017, at 21:00, David McBride wrote: > > splitOn "," <$> readFile "data.txt" > > or perhaps > > readFile "data.txt" >>= return . splitOn "," > > On Mon, Dec 11, 2017 at 3:56 PM, mike h > wrote: > >> I have >> >> input <- readFile “data.txt” >> let input’ = splitOn “,” input >> …. >> >> How do I make that into just one line? >> >> Thanks >> >> Mike >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vale.cofershabica at gmail.com Tue Dec 12 18:43:28 2017 From: vale.cofershabica at gmail.com (Vale Cofer-Shabica) Date: Tue, 12 Dec 2017 13:43:28 -0500 Subject: [Haskell-beginners] IO question In-Reply-To: References: Message-ID: I now, of course, feel silly because <$> is the infix version of fmap; apologies for list-spamming. -vale -- vale cofer-shabica 401.267.8253 On Tue, Dec 12, 2017 at 1:41 PM, Vale Cofer-Shabica < vale.cofershabica at gmail.com> wrote: > Just to add to David's answer, when I find myself in situations like: > foo >>= return . bar > > hlint helpfully suggests: > fmap bar foo > > So you could also have: > fmap (splitOn ",") $ readFile "data.txt" > > -vale > > -- > vale cofer-shabica > 401.267.8253 <(401)%20267-8253> > > On Mon, Dec 11, 2017 at 4:24 PM, mike h > wrote: > >> Thank you David. Before posting I tried readFile "data.txt" >>= … but >> got errors as I didn’t use return.!! >> >> Mike >> >> >> >> On 11 Dec 2017, at 21:00, David McBride wrote: >> >> splitOn "," <$> readFile "data.txt" >> >> or perhaps >> >> readFile "data.txt" >>= return . splitOn "," >> >> On Mon, Dec 11, 2017 at 3:56 PM, mike h >> wrote: >> >>> I have >>> >>> input <- readFile “data.txt” >>> let input’ = splitOn “,” input >>> …. >>> >>> How do I make that into just one line? >>> >>> Thanks >>> >>> Mike >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjakway at nyu.edu Tue Dec 12 18:44:24 2017 From: tjakway at nyu.edu (Thomas Jakway) Date: Tue, 12 Dec 2017 13:44:24 -0500 Subject: [Haskell-beginners] IO question In-Reply-To: References: Message-ID: Personally I prefer <$> (infix fmap) to fmap, but is this confusing to beginners? On Dec 12, 2017 10:42 AM, "Vale Cofer-Shabica" wrote: > Just to add to David's answer, when I find myself in situations like: > foo >>= return . bar > > hlint helpfully suggests: > fmap bar foo > > So you could also have: > fmap (splitOn ",") $ readFile "data.txt" > > -vale > > -- > vale cofer-shabica > 401.267.8253 <(401)%20267-8253> > > On Mon, Dec 11, 2017 at 4:24 PM, mike h > wrote: > >> Thank you David. Before posting I tried readFile "data.txt" >>= … but >> got errors as I didn’t use return.!! >> >> Mike >> >> >> >> On 11 Dec 2017, at 21:00, David McBride wrote: >> >> splitOn "," <$> readFile "data.txt" >> >> or perhaps >> >> readFile "data.txt" >>= return . splitOn "," >> >> On Mon, Dec 11, 2017 at 3:56 PM, mike h >> wrote: >> >>> I have >>> >>> input <- readFile “data.txt” >>> let input’ = splitOn “,” input >>> …. >>> >>> How do I make that into just one line? >>> >>> Thanks >>> >>> Mike >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Tue Dec 12 18:48:01 2017 From: toad3k at gmail.com (David McBride) Date: Tue, 12 Dec 2017 13:48:01 -0500 Subject: [Haskell-beginners] IO question In-Reply-To: References: Message-ID: No worries. I definitely should have mentioned fmap and <$> are the same. On Tue, Dec 12, 2017 at 1:43 PM, Vale Cofer-Shabica < vale.cofershabica at gmail.com> wrote: > I now, of course, feel silly because <$> is the infix version of fmap; > apologies for list-spamming. > > -vale > > -- > vale cofer-shabica > 401.267.8253 <(401)%20267-8253> > > On Tue, Dec 12, 2017 at 1:41 PM, Vale Cofer-Shabica < > vale.cofershabica at gmail.com> wrote: > >> Just to add to David's answer, when I find myself in situations like: >> foo >>= return . bar >> >> hlint helpfully suggests: >> fmap bar foo >> >> So you could also have: >> fmap (splitOn ",") $ readFile "data.txt" >> >> -vale >> >> -- >> vale cofer-shabica >> 401.267.8253 <(401)%20267-8253> >> >> On Mon, Dec 11, 2017 at 4:24 PM, mike h >> wrote: >> >>> Thank you David. Before posting I tried readFile "data.txt" >>= … but >>> got errors as I didn’t use return.!! >>> >>> Mike >>> >>> >>> >>> On 11 Dec 2017, at 21:00, David McBride wrote: >>> >>> splitOn "," <$> readFile "data.txt" >>> >>> or perhaps >>> >>> readFile "data.txt" >>= return . splitOn "," >>> >>> On Mon, Dec 11, 2017 at 3:56 PM, mike h >>> wrote: >>> >>>> I have >>>> >>>> input <- readFile “data.txt” >>>> let input’ = splitOn “,” input >>>> …. >>>> >>>> How do I make that into just one line? >>>> >>>> Thanks >>>> >>>> Mike >>>> _______________________________________________ >>>> Beginners mailing list >>>> Beginners at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>>> >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >>> >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >>> >> > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From theedge456 at free.fr Wed Dec 13 10:30:23 2017 From: theedge456 at free.fr (Fabien R) Date: Wed, 13 Dec 2017 11:30:23 +0100 Subject: [Haskell-beginners] How to install new GHC ? In-Reply-To: <20171212135603.61ee055f@Pavel> References: <20171212135603.61ee055f@Pavel> Message-ID: For debian users, these instructions [1] install ghc from scratch (I used the cabal part). [1] https://gist.github.com/yantonov/10083524 -- Fabien From aquagnu at gmail.com Thu Dec 14 14:33:52 2017 From: aquagnu at gmail.com (Baa) Date: Thu, 14 Dec 2017 16:33:52 +0200 Subject: [Haskell-beginners] Why exception is not catching?! Message-ID: <20171214163352.7e2033ff@Pavel> Hello, dear List! Super simple function - "safe enum conversion". It's based on `Either` because only it instantiates `MonadCatch` (Maybe does not, but with MaybeT I've got error that internal monad Indetity is not MonadCatch, so I avoid to use Maybe). That it is: data A = A1|A2 deriving (Enum, Show) data B = B1|B2|B3 deriving (Enum, Show) conv :: B -> Either SomeException A conv b = safeConv where catchError (e::SomeException) = Left e safeConv = (Right $ toEnum $ fromEnum b) `catch` catchError -- toRes (Left _) = Nothing -- toRes (Right r) = Just r But exception is not catching and I'm getting it in GHCI repl :) Exceptions are different?! What's wrong with this code? === Best regards, Paul From csasarak at mailbox.org Fri Dec 15 03:35:19 2017 From: csasarak at mailbox.org (Chris Sasarak) Date: Thu, 14 Dec 2017 22:35:19 -0500 Subject: [Haskell-beginners] Why exception is not catching?! In-Reply-To: <20171214163352.7e2033ff@Pavel> References: <20171214163352.7e2033ff@Pavel> Message-ID: <87bmj0fytk.fsf@mailbox.org> I think that this might be related to where it says in the documentation that 'catch' must be called from inside the IO monad: http://hackage.haskell.org/package/base-4.10.1.0/docs/Control-Exception-Base.html#v:catch. That doc also points to the evaluate function for details on catching exceptions in pure code. The reason it works in the GHCi repl is that GHCI is "special." Everything you evaluate it is in the IO monad/is implicitly in a 'do' block. This is why when you bind variables in GHCi you have to use 'let ' rather than 'let in '. I think that what you're running into is that because your code is implicitly in an IO action in GHCi, you can catch the exception. In compiled code (I assume this is where it's breaking?) it's a pure function though. I'd like for someone else to chime in though, at the least maybe look into using evaluate. -Chris Baa writes: > Hello, dear List! > Super simple function - "safe enum conversion". It's based on `Either` > because only it instantiates `MonadCatch` (Maybe does not, but with > MaybeT I've got error that internal monad Indetity is not MonadCatch, > so I avoid to use Maybe). That it is: > > data A = A1|A2 deriving (Enum, Show) > data B = B1|B2|B3 deriving (Enum, Show) > conv :: B -> Either SomeException A > conv b = safeConv > where catchError (e::SomeException) = Left e > safeConv = (Right $ toEnum $ fromEnum b) `catch` catchError > -- toRes (Left _) = Nothing > -- toRes (Right r) = Just r > > But exception is not catching and I'm getting it in GHCI repl :) > Exceptions are different?! What's wrong with this code? > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From aquagnu at gmail.com Fri Dec 15 08:47:24 2017 From: aquagnu at gmail.com (Baa) Date: Fri, 15 Dec 2017 10:47:24 +0200 Subject: [Haskell-beginners] Why exception is not catching?! In-Reply-To: <87bmj0fytk.fsf@mailbox.org> References: <20171214163352.7e2033ff@Pavel> <87bmj0fytk.fsf@mailbox.org> Message-ID: <20171215104724.2f098c13@Pavel> Hello, Chris! Yes, you are right. Gabriel answered already too: http://www.haskellforall.com/2012/07/errors-10-simplified-error-handling.html?showComment=1513269598213#c3541282127755203659 What I can't understand in this case is: if partial functions CAN raise "IO" exception CallError (I'm not sure in terminology here), and this exception can be catched only in IO monad, why is this not reflected in the types?! So, seems Haskell is not pure functional language, if there are such surprices. Sure, there are compromises but they can be reflected in types/signatures in some way :) Strange. Solution may be to use "spoon" package which uses `deepseq` to force to normal form but needs data to be NFData... Thanks to Gabriel for help :) === Best regards, Paul > I think that this might be related to where it says in the > documentation that 'catch' must be called from inside the IO monad: > http://hackage.haskell.org/package/base-4.10.1.0/docs/Control-Exception-Base.html#v:catch. > That doc also points to the evaluate function for details on catching > exceptions in pure code. > > The reason it works in the GHCi repl is that GHCI is "special." > Everything you evaluate it is in the IO monad/is implicitly in a 'do' > block. This is why when you bind variables in GHCi you have to use > 'let ' rather than 'let in '. I think that > what you're running into is that because your code is implicitly in > an IO action in GHCi, you can catch the exception. In compiled code > (I assume this is where it's breaking?) it's a pure function though. > > I'd like for someone else to chime in though, at the least maybe look > into using evaluate. > > -Chris > > Baa writes: > > > Hello, dear List! > > Super simple function - "safe enum conversion". It's based on > > `Either` because only it instantiates `MonadCatch` (Maybe does not, > > but with MaybeT I've got error that internal monad Indetity is not > > MonadCatch, so I avoid to use Maybe). That it is: > > > > data A = A1|A2 deriving (Enum, Show) > > data B = B1|B2|B3 deriving (Enum, Show) > > conv :: B -> Either SomeException A > > conv b = safeConv > > where catchError (e::SomeException) = Left e > > safeConv = (Right $ toEnum $ fromEnum b) `catch` catchError > > -- toRes (Left _) = Nothing > > -- toRes (Right r) = Just r > > > > But exception is not catching and I'm getting it in GHCI repl :) > > Exceptions are different?! What's wrong with this code? > > > > === > > Best regards, Paul > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From aquagnu at gmail.com Fri Dec 15 11:30:16 2017 From: aquagnu at gmail.com (Baa) Date: Fri, 15 Dec 2017 13:30:16 +0200 Subject: [Haskell-beginners] Coredump functionality for Haskell Message-ID: <20171215133016.756c0fc9@Pavel> Hello, All! In C if I need I can abort program and generate coredump - to research state of stack/vars. Is it possible in Haskell - to abort and to generate some dump which can be easy explored/researched in debugger with Haskell symbolic info (not standard Linux coredump)? And to generate it without any coding/hacking? === Best regards, Paul From mike_k_houghton at yahoo.co.uk Sun Dec 17 09:32:09 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Sun, 17 Dec 2017 09:32:09 +0000 Subject: [Haskell-beginners] function multiple args Message-ID: Hi, I have a number of functions like these: v :: Int -> [a] -> [a] w :: Int -> Int -> [a] -> [a] x :: a -> a -> [a] -> [a] y :: a -> b ->… ... -> [a] -> [a] z… etc. where there are any number of args of different types but the last two are common to all the functions i.e. they all have [a] -> [a] What I’m trying to do is build a collection (ordered) of such functions and then apply each in turn to a [a] to get the final [a]. What would be the best approach to this? Thanks Mike From peter at ireby.org.uk Sun Dec 17 13:48:44 2017 From: peter at ireby.org.uk (Peter Normington) Date: Sun, 17 Dec 2017 13:48:44 +0000 Subject: [Haskell-beginners] Int and Integer Message-ID: Why do I get an error in the following example: memoized_fib :: Integer -> Integer memoized_fib = (map fib [0 ..] !!) where fib 1 = 1 fib 2 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1) but not in: memoized_fib :: Int -> Integer memoized_fib = (map fib [0 ..] !!) where fib 1 = 1 fib 2 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1) ? The error is reported by GHCi as: error: • Couldn't match type ‘Integer’ with ‘Int’ Expected type: Integer -> Integer Actual type: Int -> Integer • In the expression: (map fib [0 .. ] !!) In an equation for ‘memoized_fib’: memoized_fib = (map fib [0 .. ] !!) where fib 1 = 1 fib 2 = 1 fib n = memoized_fib (n - 2) + memoized_fib (n - 1) | 2 | memoized_fib = (map fib [0 ..] !!) | ^^^^^^^^^^^^^^^^^ Failed, 0 modules loaded. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tanuki at gmail.com Sun Dec 17 15:40:54 2017 From: tanuki at gmail.com (Theodore Lief Gannon) Date: Sun, 17 Dec 2017 07:40:54 -0800 Subject: [Haskell-beginners] Int and Integer In-Reply-To: References: Message-ID: Because: (!!) :: [a] -> Int -> a On Dec 17, 2017 5:50 AM, "Peter Normington" wrote: > Why do I get an error in the following example: > > memoized_fib :: Integer -> Integer > memoized_fib = (map fib [0 ..] !!) > where fib 1 = 1 > fib 2 = 1 > fib n = memoized_fib (n-2) + memoized_fib (n-1) > > but not in: > > memoized_fib :: Int -> Integer > memoized_fib = (map fib [0 ..] !!) > where fib 1 = 1 > fib 2 = 1 > fib n = memoized_fib (n-2) + memoized_fib (n-1) > ? > > The error is reported by GHCi as: > > error: > • Couldn't match type ‘Integer’ with ‘Int’ > Expected type: Integer -> Integer > Actual type: Int -> Integer > • In the expression: (map fib [0 .. ] !!) > In an equation for ‘memoized_fib’: > memoized_fib > = (map fib [0 .. ] !!) > where > fib 1 = 1 > fib 2 = 1 > fib n = memoized_fib (n - 2) + memoized_fib (n - 1) > | > 2 | memoized_fib = (map fib [0 ..] !!) > | ^^^^^^^^^^^^^^^^^ > Failed, 0 modules loaded. > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter at ireby.org.uk Sun Dec 17 16:15:37 2017 From: peter at ireby.org.uk (Peter Normington) Date: Sun, 17 Dec 2017 16:15:37 +0000 Subject: [Haskell-beginners] Int and Integer Message-ID: Thanks, Theodore. As simple as that! Best regards, Peter On 17 December 2017 at 15:40, Theodore Lief Gannon wrote: > Because: > (!!) :: [a] -> Int -> a > > On Dec 17, 2017 5:50 AM, "Peter Normington" wrote: > >> Why do I get an error in the following example: >> >> memoized_fib :: Integer -> Integer >> memoized_fib = (map fib [0 ..] !!) >> where fib 1 = 1 >> fib 2 = 1 >> fib n = memoized_fib (n-2) + memoized_fib (n-1) >> >> but not in: >> >> memoized_fib :: Int -> Integer >> memoized_fib = (map fib [0 ..] !!) >> where fib 1 = 1 >> fib 2 = 1 >> fib n = memoized_fib (n-2) + memoized_fib (n-1) >> ? >> >> The error is reported by GHCi as: >> >> error: >> • Couldn't match type ‘Integer’ with ‘Int’ >> Expected type: Integer -> Integer >> Actual type: Int -> Integer >> • In the expression: (map fib [0 .. ] !!) >> In an equation for ‘memoized_fib’: >> memoized_fib >> = (map fib [0 .. ] !!) >> where >> fib 1 = 1 >> fib 2 = 1 >> fib n = memoized_fib (n - 2) + memoized_fib (n - 1) >> | >> 2 | memoized_fib = (map fib [0 ..] !!) >> | ^^^^^^^^^^^^^^^^^ >> Failed, 0 modules loaded. >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From ovidiudeac at gmail.com Mon Dec 18 15:34:32 2017 From: ovidiudeac at gmail.com (Ovidiu Deac) Date: Mon, 18 Dec 2017 17:34:32 +0200 Subject: [Haskell-beginners] function multiple args In-Reply-To: References: Message-ID: I'm not sure I understand your intention but I will try to answer though. Since your functions have different types you won't be able to put them in the same collection. Considering these two: v :: Int -> [a] -> [a] w :: Int -> Int -> [a] -> [a] You have the following options: 1. You can have a sum type to wrap them data MyFunctionType a = Vtype (Int -> [a] -> [a]) | Wtype (Int -> Int -> [a] -> [a]) then you will have your collection myFunctions = [VType v, WType w,...] then, when you apply them you will have to match and apply the function properly. 2. Another way to put them in the same collection could be to apply each of the functions partially until you are left with functions having the type ([a] -> [a]) myFunctions = [v 10, w 1 2] Does that answer your question? On Sun, Dec 17, 2017 at 11:32 AM, mike h wrote: > Hi, > > I have a number of functions like these: > > v :: Int -> [a] -> [a] > w :: Int -> Int -> [a] -> [a] > x :: a -> a -> [a] -> [a] > > y :: a -> b ->… ... -> [a] -> [a] > z… > etc. > > where there are any number of args of different types but the last two are > common to all the functions i.e. they all have [a] -> [a] > > What I’m trying to do is build a collection (ordered) of such functions > and then apply each in turn to a [a] to get the final [a]. What would be > the best approach to this? > > Thanks > > Mike > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stuart.dootson at gmail.com Mon Dec 18 16:00:39 2017 From: stuart.dootson at gmail.com (Stuart Dootson) Date: Mon, 18 Dec 2017 16:00:39 +0000 Subject: [Haskell-beginners] function multiple args In-Reply-To: References: Message-ID: Something like the code below - populate a list with partially applied functions, then use foldl to apply the functions in turn to the input list? v :: Int -> [a] -> [a] v = drop w :: Int -> Int -> [a] -> [a] w keep reject = (take keep).(drop reject) -- Apply the list of functions (in turn) to the list, yielding a list apply_ops :: [ [a] -> [a] ] -> [a] -> [a] apply_ops fns l = foldl (flip ($)) l fns -- Partially apply functions with non-list arguments to get list of functions of type [a] -> [a] ops :: [ [a] -> [a] ] ops = [v 3, w 2 1] -- result = (w 2 1) ((v 3)[1,2,3,4,5,6,7,8]) -- = w [4,5,6,7,8] -- = [5,6] result :: [Int] result = apply_ops ops [1,2,3,4,5,6,7,8] main = do print result On 17 December 2017 at 09:32, mike h wrote: > Hi, > > I have a number of functions like these: > > v :: Int -> [a] -> [a] > w :: Int -> Int -> [a] -> [a] > x :: a -> a -> [a] -> [a] > > y :: a -> b ->… ... -> [a] -> [a] > z… > etc. > > where there are any number of args of different types but the last two are > common to all the functions i.e. they all have [a] -> [a] > > What I’m trying to do is build a collection (ordered) of such functions > and then apply each in turn to a [a] to get the final [a]. What would be > the best approach to this? > > Thanks > > Mike > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike_k_houghton at yahoo.co.uk Tue Dec 19 10:04:42 2017 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Tue, 19 Dec 2017 10:04:42 +0000 Subject: [Haskell-beginners] function multiple args In-Reply-To: References: Message-ID: Thanks Stuart, Ovidiu. Yes, partially applied functions is the way. Mike > On 18 Dec 2017, at 16:00, Stuart Dootson wrote: > > Something like the code below - populate a list with partially applied functions, then use foldl to apply the functions in turn to the input list? > > v :: Int -> [a] -> [a] > v = drop > > w :: Int -> Int -> [a] -> [a] > w keep reject = (take keep).(drop reject) > > -- Apply the list of functions (in turn) to the list, yielding a list > apply_ops :: [ [a] -> [a] ] -> [a] -> [a] > apply_ops fns l = foldl (flip ($)) l fns > > -- Partially apply functions with non-list arguments to get list of functions of type [a] -> [a] > ops :: [ [a] -> [a] ] > ops = [v 3, w 2 1] > > -- result = (w 2 1) ((v 3)[1,2,3,4,5,6,7,8]) > -- = w [4,5,6,7,8] > -- = [5,6] > result :: [Int] > result = apply_ops ops [1,2,3,4,5,6,7,8] > > main = > do > print result > > On 17 December 2017 at 09:32, mike h > wrote: > Hi, > > I have a number of functions like these: > > v :: Int -> [a] -> [a] > w :: Int -> Int -> [a] -> [a] > x :: a -> a -> [a] -> [a] > > y :: a -> b ->… ... -> [a] -> [a] > z… > etc. > > where there are any number of args of different types but the last two are common to all the functions i.e. they all have [a] -> [a] > > What I’m trying to do is build a collection (ordered) of such functions and then apply each in turn to a [a] to get the final [a]. What would be the best approach to this? > > Thanks > > Mike > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at maximka.de Fri Dec 29 15:52:10 2017 From: info at maximka.de (info at maximka.de) Date: Fri, 29 Dec 2017 16:52:10 +0100 (CET) Subject: [Haskell-beginners] type family exercise Message-ID: <2092666003.437685.1514562730506@communicator.strato.de> There is a little exercise at the end of the post "Type Tac Toe: Advanced Type Safety" http://chrispenner.ca/posts/type-tac-toe > As an exercise try combining playX and playO into a more general play! Here's a hint, you'll want to make another wrapper type like we did with Coord! Link to the code https://github.com/ChrisPenner/Type-Tac-Toe/blob/master/src/TypeTacToe.hs Unfortunately I couldn't solve it by myself. The only generalised play I could implement is here: play :: (Played x y b ~ 'False) => (Coord x, Coord y) -> Board b PieceT -> PieceT -> Board b PieceT play (coordVal -> x, coordVal -> y) (Board b) p = Board $ overTrip y (overTrip x (const p)) b I would be very grateful for any help to solve the exercise by using type family extension. Regards, Alexei From trent.shipley at gmail.com Sun Dec 31 04:01:51 2017 From: trent.shipley at gmail.com (trent shipley) Date: Sun, 31 Dec 2017 04:01:51 +0000 Subject: [Haskell-beginners] Simplified Luhn Algorithm Message-ID: I have the following, and it works, but I am trying teach myself Haskell, and I have the suspicion that my solutions is both inefficient and graceless. Any feedback would be appreciated. Trent. ------------------------------------ {- 8.The Luhn algorithm is used to check bank card numbers for simple errors such as mistyping a digit, and proceeds as follows: * consider each digit as a separate number; * moving left, double every other number from the second last; * subtract 9 from each number that is now greater than 9; * add all the resulting numbers together; * if the total is divisible by 10, the card number is valid. Define a function luhnDouble :: Int -> Int that doubles a digit and subtracts 9 if the result is greater than 9. For example: > luhnDouble 3 6 > luhnDouble 6 3 Using luhnDouble and the integer remainder function mod, define a function luhn :: Int -> Int -> Int -> Int -> Bool that decides if a four-digit bank card number is valid. For example: > luhn 1 7 8 4 True > luhn 4 7 8 3 False In the exercises for chapter 7 we will consider a more general version of this function that accepts card numbers of any length. Hutton, Graham. Programming in Haskell (pp. 45-46). Cambridge University Press. Kindle Edition. -} luhnDouble :: Int -> Int luhnDouble x = if (2 * x) > 9 then (2 * x) - 9 else 2 * x luhn :: Int -> Int -> Int -> Int -> Bool luhn x1 x2 x3 x4 = if 0 == sum[luhnDouble x1, x2, luhnDouble x3, x4] `mod` 10 then True else False -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrik.mrx at gmail.com Sun Dec 31 08:49:12 2017 From: patrik.mrx at gmail.com (mrx) Date: Sun, 31 Dec 2017 09:49:12 +0100 Subject: [Haskell-beginners] Simplified Luhn Algorithm In-Reply-To: References: Message-ID: I guess your issue is how to represent the card numbers of arbitrary length, or? Wouldn't a list work? Patrik Den 31 dec 2017 05:03 skrev "trent shipley" : I have the following, and it works, but I am trying teach myself Haskell, and I have the suspicion that my solutions is both inefficient and graceless. Any feedback would be appreciated. Trent. ------------------------------------ {- 8.The Luhn algorithm is used to check bank card numbers for simple errors such as mistyping a digit, and proceeds as follows: * consider each digit as a separate number; * moving left, double every other number from the second last; * subtract 9 from each number that is now greater than 9; * add all the resulting numbers together; * if the total is divisible by 10, the card number is valid. Define a function luhnDouble :: Int -> Int that doubles a digit and subtracts 9 if the result is greater than 9. For example: > luhnDouble 3 6 > luhnDouble 6 3 Using luhnDouble and the integer remainder function mod, define a function luhn :: Int -> Int -> Int -> Int -> Bool that decides if a four-digit bank card number is valid. For example: > luhn 1 7 8 4 True > luhn 4 7 8 3 False In the exercises for chapter 7 we will consider a more general version of this function that accepts card numbers of any length. Hutton, Graham. Programming in Haskell (pp. 45-46). Cambridge University Press. Kindle Edition. -} luhnDouble :: Int -> Int luhnDouble x = if (2 * x) > 9 then (2 * x) - 9 else 2 * x luhn :: Int -> Int -> Int -> Int -> Bool luhn x1 x2 x3 x4 = if 0 == sum[luhnDouble x1, x2, luhnDouble x3, x4] `mod` 10 then True else False _______________________________________________ Beginners mailing list Beginners at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnlusk4 at gmail.com Sun Dec 31 14:10:28 2017 From: johnlusk4 at gmail.com (John Lusk) Date: Sun, 31 Dec 2017 09:10:28 -0500 Subject: [Haskell-beginners] Simplified Luhn Algorithm In-Reply-To: References: Message-ID: Looks fine to me. Maybe drop the if-then, and simply return the result of the == ? (Maybe not possible in Haskell (I'm just a duffer myself) but extraneous trues and falses always drive me nuts.) -- Sent from my tablet, which has a funny keyboard. Makes me sound more curt and muted than normal. On Dec 30, 2017 11:03 PM, "trent shipley" wrote: > I have the following, and it works, but I am trying teach myself Haskell, > and I have the suspicion that my solutions is both inefficient and > graceless. Any feedback would be appreciated. > > Trent. > > ------------------------------------ > > {- > 8.The Luhn algorithm is used to check bank card numbers for simple errors > such as mistyping a digit, and proceeds as follows: > > * consider each digit as a separate number; > * moving left, double every other number from the second last; > * subtract 9 from each number that is now greater than 9; > * add all the resulting numbers together; > * if the total is divisible by 10, the card number is valid. > > Define a function luhnDouble :: Int -> Int that doubles a digit > and subtracts 9 if the result is greater than 9. > > For example: > > > luhnDouble 3 > 6 > > > luhnDouble 6 > 3 > > Using luhnDouble and the integer remainder function mod, define a function > luhn :: Int -> Int -> Int -> Int -> Bool > that decides if a four-digit bank card number is valid. > > For example: > > luhn 1 7 8 4 > True > > > luhn 4 7 8 3 > False > > In the exercises for chapter 7 we will consider a more general version of > this function that accepts card numbers of any length. > > Hutton, Graham. Programming in Haskell (pp. 45-46). Cambridge University > Press. Kindle Edition. > -} > > luhnDouble :: Int -> Int > luhnDouble x = if (2 * x) > 9 > then (2 * x) - 9 > else 2 * x > > > luhn :: Int -> Int -> Int -> Int -> Bool > luhn x1 x2 x3 x4 = if 0 == sum[luhnDouble x1, x2, luhnDouble x3, x4] `mod` > 10 > then True > else False > > > > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rpglover64 at gmail.com Sun Dec 31 15:06:36 2017 From: rpglover64 at gmail.com (Alex Rozenshteyn) Date: Sun, 31 Dec 2017 15:06:36 +0000 Subject: [Haskell-beginners] Simplified Luhn Algorithm In-Reply-To: References: Message-ID: Haskell can totally return the result of the "==", and that would be one of my suggestions as well. The other suggestion is for "luhnDouble": I would just compute `rem (2 * x) 9`, but if you need to explicitly subtract, you can do `let d = 2 * x in if d > 9 then d - 9 else d`, which does the computation just once. On Sun, Dec 31, 2017 at 9:12 AM John Lusk wrote: > Looks fine to me. Maybe drop the if-then, and simply return the result of > the == ? (Maybe not possible in Haskell (I'm just a duffer myself) but > extraneous trues and falses always drive me nuts.) > > -- > Sent from my tablet, which has a funny keyboard. Makes me sound more curt > and muted than normal. > > On Dec 30, 2017 11:03 PM, "trent shipley" wrote: > >> I have the following, and it works, but I am trying teach myself Haskell, >> and I have the suspicion that my solutions is both inefficient and >> graceless. Any feedback would be appreciated. >> >> Trent. >> >> ------------------------------------ >> >> {- >> 8.The Luhn algorithm is used to check bank card numbers for simple errors >> such as mistyping a digit, and proceeds as follows: >> >> * consider each digit as a separate number; >> * moving left, double every other number from the second last; >> * subtract 9 from each number that is now greater than 9; >> * add all the resulting numbers together; >> * if the total is divisible by 10, the card number is valid. >> >> Define a function luhnDouble :: Int -> Int that doubles a digit >> and subtracts 9 if the result is greater than 9. >> >> For example: >> >> > luhnDouble 3 >> 6 >> >> > luhnDouble 6 >> 3 >> >> Using luhnDouble and the integer remainder function mod, define a >> function >> luhn :: Int -> Int -> Int -> Int -> Bool >> that decides if a four-digit bank card number is valid. >> >> For example: >> > luhn 1 7 8 4 >> True >> >> > luhn 4 7 8 3 >> False >> >> In the exercises for chapter 7 we will consider a more general version of >> this function that accepts card numbers of any length. >> >> Hutton, Graham. Programming in Haskell (pp. 45-46). Cambridge University >> Press. Kindle Edition. >> -} >> >> luhnDouble :: Int -> Int >> luhnDouble x = if (2 * x) > 9 >> then (2 * x) - 9 >> else 2 * x >> >> >> luhn :: Int -> Int -> Int -> Int -> Bool >> luhn x1 x2 x3 x4 = if 0 == sum[luhnDouble x1, x2, luhnDouble x3, x4] >> `mod` 10 >> then True >> else False >> >> >> >> >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: