-
Stack Overflow sml ocaml haskell types type-theory functional-programming ecmascript-harmony ml oz mozart alice scheme r6rs standard-ml
-
Theoretical Computer Science type-theory functional-programming
Ocaml syntax - procedure
I'm ocaml absolute beginner and I'm writing some code for classes and I've got a problem with such a line: let rec distributeLeft(X, And(e,f)) = And(distributeLeft(X, e),distributeLeft(Y, f)) | ...
Running Standard ML on Windows
I have been looking for some good documentation on how to get Standard ML running on windows. Does anyone have a good guide on this? I have tried compiling sml/nj in cygwin, using this guide: ...
Using ReaderT to create a modifiable environment
I have been following and expanding on the tutorial Write Yourself A Scheme. I have a type LispVal wrapped up in a couple of layers of monad transformers: import qualified Data.Map as M data LispVal …
Static linking wxHaskell on Mac OS X
I want to distribute a wxHaskell application on Mac OS X. How do I go about creating a Mac OS X app which can be used standalone without the user having to install any extra libraries? I noticed the …
How to check that a string is an int, but not a double, etc.?
PHP has an intval() function that will convert a string to an integer. However I want to check that the string is an integer beforehand, so that I can give a helpful error message to the user if it's …
Purely functional set
Is there an algorithm that implements a purely functional set? Expected operations would be union, intersection, difference, element?, empty? and adjoin. Those are not hard requirements though and I …
How can I get a property name for a type without the need to instantiate an object of that type?
I have a requirement where I need to have a "type safe" way of accessing property names, without actually instantiating an object to get to the property. To give an example, consider a method that …
Use function after generated by extraction from Coq to Ocaml
I have a folder tmp which is generated after I do extraction from coq to ocaml. ~/tmp/cpf0.ml cpf0.mli cpf0.o cpf0.cmi cpf0.cmx cpf0.cmo main.ml is a file I use to call one function in cpf0 : let …
How can you map and cast unknown types in Java when using reflection?
I'm using reflection to map getters from one class to setters in another i.e. I have form classes used by stuts1 for display mostly text (Strings) and I have pure Java objects used by the back end ...
Iterating over a list
I am trying to learn Haskell from Haskell Road to Logic and came across this example: mnmInt :: [Int] -> Int mnmInt [] = error "empty list"· mnmInt [x] = x mnmInt (x:xs) = min x …
What characters are permitted for haskell operators?
Is there a complete list of allowed characters somewhere, or a rule that determines what can be used in an identifier vs an operator?
Is currying the same as overloading?
Is currying for functional programming the same as overloading for OO programming? If not, why? (with examples if possible) Tks
Convert string to code in Scheme
How do I convert a string into the corresponding code in PLT Scheme (which does not contain the string->input-port method)? For example, I want to convert this string: "(1 (0) 1 (0) 0)" into …
Parsing JSON string into record in Haskell
I'm struggling to understand this (I'm still a bit new to Haskell) but I'm finding the documentation for the Text.JSON package to be a little confusing. Basically I have this data record type: - data …
How can I uninstall a version of a Cabal package?
Happstack Lite is breaking on me because it's getting blaze-html version 0.5 and it wants version 0.4. Cabal says that both versions 0.4.3.4 and 0.5.0.0 are installed. I want to remove the 0.5.0.0 …
Haskell “exceptions”
I've got a set of users, groups, and a mapping between users and groups. I have various functions that manipulate these sets, however one should not be able to add a user<->group mapping for a user …
Making a simple post request with parameters and receiving a response
I want to duplicate this functionality: curl -d "user=username&passwd=passwd&api_type=json" http://www.reddit.com/api/login/username I have run across at least 3 libraries that offer this …
Why is it so uncommon to use type signatures in where clauses?
Does it help the compiler to optimise, or is it just surplus work to add additional type signatures? For example, one often sees: foo :: a -> b foo x = bar x where bar x = undefined Rather …
Is JavaScript an untyped language?
I've found that some people call JavaScript a "dynamically, weakly typed" language, but some even say "untyped"? Which is it really?
Encapsulating data definitions in Haskell
I am trying to define a data type using other data types like this: data A = Something String | SomethingElse Int data B = Another B | YetAnother A data C = A | B x :: [ C ] x = [ YetAnother ...
Ocaml efficient quicksort
I'd like to know how can write an efficient version of quicksort where list is partitioned in one pass. I've this fragment of code, let rec quicksort' = function [] -> [] | x::xs -> let …
Can a Haskell or Haskell OS thread waiting on Network.Socket.accept not be killed on Windows?
-- thread A t <- forkIO $ do _ <- accept listener -- blocks -- thread B killThread t works on Linux (probably also on OS X and FreeBSD) but not on Windows (tried -threaded with +RTS …
Fault tolerant JSON parsing
I'm using Data.Aeson to parse some JSON into a Record type. From time to time data is added to the JSON and this breaks my code as Aeson complains something to the effect of: expected Object with …
Should I create a function to enter data into another function?
I'm teaching myself to program in Haskell, and I'm working on a find function. What it does is it takes two strings, such as "hello" and "he", and it counts how many times "he" appears in "hello". …
I have multiple installed versions of the same haskell/cabal package. Which one is put into use?
Main question: I have multiple versions of a package installed. How can I know which version is being put into use when compiling or running, in ghc/ghci, a module having a module in the package as a …
Using Cont to acquire values from the future and the past
I'm writing a brainfuck interpreter in Haskell, and I came up with what I believe to be a very interesting description of a program: data Program m = Instruction (m ()) (Program m) | …
Why all the lambdas in The Little Schemer?
After learning a bit of Scheme from SICP, I started reading The Little Schemer (which I find quite entertaining) and am about one fourth done. I noticed that I can write many (most? all?) solutions …
What are the alternatives for accomplishing this same task?
I have a structure that is instantiated in a parent function and I want to modify that instantiated data with calls to functions from that parent function. Here's a contrived example: import ...
Haskell: Flatten binary tree
I was thinking about flattening a binary tree to a list, for latter processing. I first thought of using (++) to join the left and right branches, but then thought in the worse case that would take …
“Many functions operating upon few abstractions” principle vs OOP
The creator of the Clojure language claims that "open, and large, set of functions operate upon an open, and small, set of extensible abstractions is the key to algorithmic reuse and library ...