Stream

Join this community to post or comment
 
There's a little known library called Numeric.Natural. It represents arbitrary Natural Numbers efficiently (it is basically Integer without negatives.) It makes it impossible to have negative numbers. For example, if you did:

fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)

Normally you would have to check if n is negative at run time, but by restricting the type to fib :: Natural -> Natural, you don't have to worry about it. It is also compatible with most code due to polymorphism (although for lists you will need the generic functions.)
Type representing arbitrary-precision non-negative integers. Operations whose result would be negative throw ( Underflow :: ArithException ) . Since: 4.8.0.0. Instances. Enum Natural Source · Eq Natural Source · Integral Natural Source · Data Natural Source · Num Natural Source ...
8
1
Yuji Yamamoto's profile photoChristopher King's profile photoPhilip Thrift's profile photo
2 comments
 
+Yuji Yamamoto Word has a maximum number it can not go past, so it is like Int. Natural does not have a maximum or upper bound, and so is like Integer.
Add a comment...

Johan Tibell
moderator

Announcement  - 
 
Students, we need more infrastructure proposals for this year's haskell.org Google Summer of Code. I'd like to see more projects for e.g. improving some aspect of Cabal or Hackage. Apply at: https://www.google-melange.com/gsoc/org2/google/gsoc2015/haskell
5
2
Michal Terepeta's profile photoDrazen Popović's profile photo
Add a comment...

Paul S

Help and Advice  - 
 
Hi Haskellers, newbie here.  I'm trying to install the Haste compiler, and I  am getting an error when I run haste-boot:

Missing (or bad) header file: HsBase.h

Details here:   http://lpaste.net/128202

Would really appreciate any pointers please.

Thanks,

Paul
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17, Installed latest Haskell Platform (haskell-platform-2014.2.0.0-unknown-linux-x86_64.tar.gz ) cabal update Compile and install zlib-1.2.8 cabal install cabal-install sudo apt-get install bzip2 libbz2-dev cabal install haste-compiler haste-boot .
1
Paul S's profile photo
3 comments
Paul S
 
I installed the packaged GHC on Linux Mint 13 and everything worked!  Thanks for the tip!
Add a comment...

dolph das

Announcement  - 
 
Comprehensive categorical Haskell, human readable.
\(\newcommand{\F}{\mathbf{F}}\) \(\newcommand{\E}{\mathbf{E}}\) \(\newcommand{\C}{\mathcal{C}}\) \(\newcommand{\D}{\mathcal{D}}\) \(\newcommand{\id}{\mathrm{id}}\) \(\newcommand{\ob}[1]{\mathrm{ob}(#1)}\) \(\newcommand{\hom}[1]{\mathrm{hom}(#1)}\) \(\newcommand{\Set}{\mathbf{Set}}\) ...
19
5
Gabriel Pozo's profile photoYuji Yamamoto's profile photochangsheng liu's profile photoWilliam Rutiser's profile photo
 
You should put link to the first slide. Or makes us confused a little.
http://yogsototh.github.io/Category-Theory-Presentation/
Add a comment...

Johan Tibell
moderator

Discussion  - 
 
I've put together a list of Google Summer of Code 2015 project ideas: http://blog.johantibell.com/2015/03/google-summer-of-code-2015-project-ideas.html
9
Add a comment...
 
Why not instead of making 0 special, use Maybe Integer?
2
Christopher King's profile photo
 
Over even just use Maybe PostId where you need it.
Add a comment...

Nakazo Moto

Discussion  - 
 
Best explanation of the IO monad I have see so far
IO. CIS 194 Week 8 11 March 2013. Suggested reading: LYAH Chapter 9: Input and Output · RWH Chapter 7: I/O. The problem with purity. Remember that Haskell is lazy and therefore pure. This means two primary things: Functions may not have any external effects. For example, a function may not print ...
26
8
Yves Parrays's profile photoChris Jenkins's profile photoJulian Fleischer's profile photoWilliam Rutiser's profile photo
4 comments
Add a comment...

dolph das

Discussion  - 
9
Boyd Smith's profile photoGiorgio Mossa's profile photo
5 comments
 
+dolph das what don't you understand? the more the details you add the more easy will be for other to help. 
Add a comment...
 
I am teaching functional programming, and would like to use Haskell for Internet applications on a CGI gate.  I am not able to compile programs on the server. Using Clean or Racket, it is easy to compile  programs in my Linux machine and use scp to send thom to the server.  However Haskell simply does not work when I install the compiled programs in the server machine.  I compile the Haskell program thus:

ghc --make -static -optc-static -optl-static roda.hs -optl-pthread -o xroda.k

The program is very simple:

import System.IO

main = do
   putStrLn "Content-type text/html"
   putStrLn ""
   putStrLn "<html><body><h1>Hello</h1></body></html>"
   hFlush stdout

The compiled program does not print anything, but freezes the machine for a long time, until I get an out of memory message. By the way, the Clean program that works flawlessly is compiled by the following command line:

bin/clm -nt -nr internet -o internet.k
2
1
Overmind Jiang's profile photoEduardo Costa's profile photoYuji Yamamoto's profile photo
2 comments
 
Hi, Jiang.
The problem is that I failed to build GHC anywhere. I was able to install binaries in machine where binaries are available, and that is all. When I try to install any thing from source or update from sources, I get messages like that:

zlib-0.5.4.2 failed during the building phase. The exception was:
>> ExitFailure 1

together with the suggestion:

(dist/package.conf.inplace) use 'ghc-pkg init' to create the database with
>> the correct format.

Of course, the suggestion does not work either. What amazes me is that Clean is practically dead (people do not improve the compiler since 2011), but it works flawlessly, without bugs, and it is very easy to build from sources. I don't like uniqueness types, but I am afraid that I will be forced into Clean.
Add a comment...
 
Programming with Refinement Types, an intro to SMT and LiquidHaskell with exercises.
http://ucsd-progsys.github.io/liquidhaskell-tutorial/
http://ucsd-progsys.github.io/liquidhaskell-tutorial/book.pdf
Programming with Refinement Types. An Introduction to LiquidHaskell. Ranjit Jhala, Eric Seidel, Niki Vazou. 1.Introduction · 1.1. Well-Typed Programs Do Go Wrong · 1.2. Refinement Types · 1.3. Audience · 1.4. Getting Started · 1.5. Sample Code · 2.Logic & SMT · 2.1. Syntax · 2.2.
11
7
William Rutiser's profile photomukesh tiwari's profile photo
Add a comment...
 
Lots of juicy tidbits here.
GHC has implemented "The Applicative Monad Proposal", meaning the Applicative typeclass is now a superclass of Monad . This is a breaking change and your programs will need to be updated. Please see the GHC 7.10 Migration Guide on the GHC wiki. GHC has implemented the "Burning Bridges Proposal", ...
5
Add a comment...

Paul S

Help and Advice  - 
 
How do I resolve this error message?

Failed to load interface for ‘Control.Monad.State’
    It is a member of the hidden package ‘monads-tf-0.1.0.2’.

I`m running haste compiler on hplayground:

paul@mint64~/hplayground/src $ hastec Main.hs --output-html

Haste/HPlay/View.hs:72:1:
    Failed to load interface for ‘Control.Monad.State’
    It is a member of the hidden package ‘monads-tf-0.1.0.2’.
1
Aleksey “astynax” Pirogov's profile photo
 
You can try to add "monads-tf" to the list of dependencies in your .cabal-file, and then run "cabal configure"
Add a comment...

dolph das

Help and Advice  - 
 
How to make Haskell code run on android with jhc and ndk? For examples, I just want to write a function of type string->string, which should be trivial, but can not figure out how to set up jhc after reading its manual
1
Zsolt Szatmári's profile photodolph das's profile photo
2 comments
 
+Zsolt Szatmári I have seen running examples with ghc, but it seems rather complex to make ghc a cross compiler.but with jhc, u can simply target it to c,then use ndk
Add a comment...

Ivan Miljenovic

Discussion  - 
 
So, just by starting to write tests I found a long-standing bug in fgl: for the two defined Graph instances, the nodeRange of an empty graph is the same as for a graph with only a single node with an ID of `0`.

The way I see it, there are four possible options:

1) Make this dodgy behaviour "official" (in that the default method definition also does this)

2) `nodeRange empty` throws an error (this is what the default definition does, albeit because `minimum []` fails)

3) Turn this into a Maybe, thus breaking the API

4) `nodeRange empty` returns `(maxBound, minBound)` (or some other nonsensical range)

I'm currently leaning towards the fourth option (if it wasn't that I want to keep the current API as stable as possible I would go towards the third one).
(c) 1999 - 2002 by Martin Erwig [see file COPYRIGHT] -- | Tree-based implementation of 'Graph' and 'DynGraph' module Data.Graph.Inductive.Tree (Gr,UGr) where import Data.List (foldl') import Data.Graph.Inductive.Graph import Data.Graph.Inductive.Internal.FiniteMap import Data.
7
Ivan Miljenovic's profile photo
7 comments
 
Looks like I might need to do a major version bump any way: the definition of `equal` doesn't work with multiple edges; fixing it requires changing an Eq constraint to Ord (or else just deprecating, but PVP says that should count as removal). :s
Add a comment...

Adrian “Boom” Nwk

Help and Advice  - 
 
Hello fellow Haskellers, I was trying to do some practice on writing functional data types (using the data keyword to create types) and I found when I try to find the type of an enumerator of colours it says Not in scope: data constructor ‘Colour’ . Can anybody help me out ? 

code : http://pastebin.com/RD4FJ1sV
2
Adrian “Boom” Nwk's profile photoSimon Clarkstone's profile photo
8 comments
 
You can't say ":t Colour" because Colour isn't an expression; it's a type.

You could write ":k Colour" but that just says "*" because Colour has no type parameters.
You can also say ":i Colour" and get some information about the type.
And you can say ":browse" to get a list of defined things.
Add a comment...

dolph das

Announcement  - 
 
Purescript, maybe the best solution to js problem,compiled is runtime is about 35kb
2
1
William Rutiser's profile photo
Add a comment...

dolph das

Discussion  - 
 
Arrow vs monad,a comprehensive discussion
I've reading the "The Typeclassopedia" by Brent Yorgey in Monad.Reader#13 ,and found that "the Functor hierachy" is interdependent of "the Category hierachy" as the Figure.1 shown. And according ...
9
1
dolph das's profile photoGabor Greif's profile photoWilliam Rutiser's profile photo
3 comments
 
Should have said AMP (applicative-monad-proposal). It will be part of GHC 7.10 and make Applicative a superclass of Monad. Looking at the picture again, I see it is already anticipated. I should be more careful with my comments :-(
Add a comment...

Ivan Miljenovic

Help and Advice  - 
 
Since I've suddenly started clean-up work on fgl, I thought I'd actually go ahead and finally start writing a test-suite.  Thing is, what's the best way of dealing with Arbitrary instances QuickCheck?

I can of course just define it within the testing module(s), but I want to be able to access these instances from other packages (and thus remove the Arbitrary instance I have within graphviz).

Should I make fgl depend upon QuickCheck (they're both HP packages, so it's not as bad as it could be)?  Or just resign myself to copy-pasta?

(I think the real solution is to be able to have multiple libraries definable within the one Cabal package with separate dependencies; so that way you can depend upon fgl-quickcheck to get the instances but if you don't depend on that library then you don't have a dependency upon QuickCheck.  I realise that this isn't feasible any time soon due to the large amount of work required though.)
2
2
Ivan Miljenovic's profile photoNoam Lewis's profile photoYuji Yamamoto's profile photoDave Gordon's profile photo
8 comments
 
Incidentally I've just used fgl - thanks for maintaining it!
Add a comment...

Levent Erkok

Announcement  - 
 
 
A new release of SBV is out:

http://hackage.haskell.org/package/sbv-4.1

Thanks to +Adam Foltzer of +Galois, Inc. and +Alan Mischenko from Berkeley, SBV can now talk to Berkeley's ABC (http://www.eecs.berkeley.edu/~alanmi/abc/), which is an industrial strength synthesis and verification system. 
Express properties about Haskell programs and automatically prove them using SMT (Satisfiability Modulo Theories) solvers. For details, please see: http://leventerkok.github.com/sbv/. Release notes: http://github.com/LeventErkok/sbv/blob/master/CHANGES.md ...
1 comment on original post
9
4
Andy Adams-Moran's profile photosuhorng Y's profile photoArtem Zvyagintsev's profile photoYuriy Pitometsu's profile photo
2 comments
 
+roux cody SBV used to support array-models with old versions of Yices; pre its 2.0 releases. If you can get your hands on an old version of Yices you can still use it to extract array models. With SMT2-Lib based approach (which is behind all the new backends), array-models are not directly extractable; but rather they can be accessed programmatically by explicitly naming the elements of interest. Would be happy to help if you try this and have issues with it. (Unfortunately SMTLib does not yet define a standard way of accessing array models.)
Add a comment...