4 ms·
I have heard similar opinions on Haskell. I am definitely attracted to the convenient function currying and composition, but I realized I could do similar in C
by Xurinos 16y ago
I have heard similar opinions on Haskell. I am definitely attracted to the convenient function currying and composition, but I realized I could do similar in CL and make it look like whatever made sense to me. I find the ability to create my own look and feel to supercede accepting someone else's look and feel.
I have no issues with Scheme, except that I have chosen to use CL over Scheme because it does feel like something of a batteries-included system.
On the other hand, I was annoyed by what I felt was inconsistent syntax with Haskell revealed in Real World Haskell chapter 13 (unfortunately my only experience with it) when they showed this function definition:
mkFuncRec :: String -> (Int -> Int) -> FuncRec
vs this function definition:
simplify :: (Num a) => SymbolicManip a -> SymbolicManip a
The =>, previously used to instance types, confused me here (they never explained how this definition differed), and I was having a hard time keeping up with all the various times I needed to use each special symbol. Of course, I tolerated it through C++ and perl, so if I ever decided to try a project, I could probably get used to it.
- eru 16y agoI see that the namespaces for values and types are somewhat separate in Haskell. Could you please describe your confusion again in different words? Perhaps I am too used to Haskell, but I do not see anything confusing in those two definitions. What do you mean with "previously used to instance types"? As far as I can remember => is only ever used in the context shown above.
- Xurinos 16y agoThe book introduced the second pattern out of the blue. What is the difference between those two function definitions? What does "=>" mean in this context? a :: b -> (c d) -> e makes sense to me, but f :: (g h) => i -> j -> k does not. Here is the page that suddenly introduced that second form: http://book.realworldhaskell.org/read/data-structures.html http://book.realworldhaskell.org/read/data-structures.html It is entirely possible I missed some context somewhere in there; "namespaces for values vs types" might be my clue. :)
- eru 16y agoIn the example my_fun :: (TypeClass1 a, Typeclass2 b) => a -> b the stuff preceeding the => declares what typeclasses the types you mention later should fall into. A good example is the module Data.Map; this module deals with finite mappings of keys to values. Since those Maps are based on balanced trees, the keys have to be orderable/comparable. So for inserting a key into a map (http://hackage.haskell.org/packages/archive/containers/0.2.0.1/doc/html/Data-Map.html#5 http://hackage.haskell.org/packages/archive/containers/0.2.0...) we get the following type insert :: Ord k => k -> a -> Map k a -> Map k a This just says that the type of keys has to be an instance of the class Ord (http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Data-Ord.html http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0...). I.e. there has to be an instance declaration with the function (<=) :: a -> a -> Bool Does that help? By the way, if you want to find documentation about a function and you know its name or type, you can use Hoogle (http://www.haskell.org/hoogle/ http://www.haskell.org/hoogle/).
- Xurinos 16y agothe stuff preceeding the => declares what typeclasses the types you mention later should fall into. That makes it clear. Thank you!