News aggregator

Feature request: Vacuous/error constraint (related to 7.7 closed type families regression)

glasgow-user - Tue, 01/14/2014 - 3:56pm
I was trying to fix one of my closed type families examples for the new syntax, and run into an unfortunate issue. Due to a kind error in my code one of my constraints was being silently discarded (see ticket: The main reason I resorted to this (in hindsight) ill-kinded hack is the lack of a vacuous (i.e. never holding) constraint to produce type errors. I would love to be able to explicitly force GHC into realising "this constraint can never hold", if I had the ability to pass along a String/Symbol to be reported to the user, that would be even better. Cheers, Merijn _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users< at >
Categories: Offsite Discussion

Brent Yorgey: Catsters guide

Planet Haskell - Tue, 01/14/2014 - 3:06pm


In an attempt to solidify and extend my knowledge of category theory, I have been working my way through the excellent series of category theory lectures posted on Youtube by Eugenia Cheng and Simon Willerton, aka the Catsters.

Edsko de Vries used to have a listing of the videos, but it is no longer available. After wresting a copy from a Google cache, I began working my way through the videos, but soon discovered that Edsko’s list was organized by subject, not topologically sorted. So I started making my own list, and have put it up here in the hopes that it may be useful to others. Suggestions, corrections, improvements, etc. are of course welcome!

As far as possible, I have tried to arrange the order so that each video only depends on concepts from earlier ones. Along with each video you can also find my cryptic notes; I make no guarantee that they will be useful to anyone (even me!), but hopefully they will at least give you an idea of what is in each video.

I have a goal to watch two videos per week (at which rate it will take me about nine months to watch all of them); I will keep the list updated with new video links and notes as I go.

Categories: Offsite Blogs

Target Selection in HaRe

haskell-cafe - Tue, 01/14/2014 - 12:04pm
The Haskell Refactorer now makes use of the GHC API to load and typecheck the code to be refactored. It uses ghc-mod internally to identify a project cabal file, and extract the targets in it. The current code attempts to load all the targets into the module graph, to make sure that when a project is refactored the ancillary parts such as tests and benchmarks are refactored too, e.g. when renaming a function. The problem is that GHC is unable to load more than one main file. I am trying to decide on the best way of resolving this in terms of a user of HaRe, where it should 'just work' most of the time. The actual refactoring is done by calling the HaRe executable with command line arguments. Options that seem viable are 1. require the names of the target(s) to be loaded to be passed in as command line arguments. This means the IDE integration is going to have to provide a way of deciding the scope of the refactoring. 2. Create a config file that lives in the project directory and specifies the target
Categories: Offsite Discussion

Ask /r/haskell: how to implement a symbol table for a compiler in a purely functional language?

Haskell on Reddit - Tue, 01/14/2014 - 12:03pm

Hello everyone,

Last semester in school, I took a compiler construction class, and wrote a compiler for a small imperative language in Python. I've been meaning to try and write a compiler for an OO language, and also to do a larger project in Haskell. I thus decided to implement Alex Aiken's COOL language (see Coursera for more information) in Haskell.

So far, I have my lexer, parser and pretty printer and they work well. I'm now at the semantics analysis phase, but I'm not sure what would be a good way to implement a symbol table in Haskell. By that I mean, I'm not sure where the table should reside. Should it be a value that's computed once by a function and passed around to every other function that needs it? Should I put symbol information in the attribute field of my AST nodes?

If anyone has suggestions and/or reading material recommendations, I'd be very grateful.


submitted by gnuvince
[link] [9 comments]
Categories: Incoming News

Functors are Containers

Haskell on Reddit - Tue, 01/14/2014 - 11:43am
Categories: Incoming News - Tue, 01/14/2014 - 9:13am
Categories: Offsite Blogs

flip1 through flip9, useful?

haskell-cafe - Tue, 01/14/2014 - 7:48am
I have defined a bunch of functions like this: -- | Move the fourth argument to the first place rotate4 :: (a -> b -> c -> d -> e) -> (d -> a -> b -> c -> e) -- | Reverse four arguments flip4 :: (a -> b -> c -> d -> e) -> (d -> c -> b -> a -> e) I decided to upload this as a library to hackage, as I personally find it useful, especially for writing FFI bindings. It seems like I can't be the first to write a library like this though, am I missing something obvious? Is this useful or stupid? Does it exist already? Full definition here: _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Records vs Tuples

haskell-cafe - Tue, 01/14/2014 - 5:58am
What exactly is the purpose in having both records and tuples? They seem to behave rather similarly although records do have the extra naming of the fields that tuples don't.
Categories: Offsite Discussion

Error management in Happstack

haskell-cafe - Mon, 01/13/2014 - 11:50pm
Hi Jeremy, all, In Happstack when I throw an error, I obtain a blank page with "server error: my message". How can I decorate this page? I'd like to have it look like the other pages of my website, and a "back to login" link, for example. Thanks! Corentin _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

OT - targeting many systems

haskell-cafe - Mon, 01/13/2014 - 11:15pm
I love Haskell, and it gets many things right. However eg its hard to target JS in an efficient way. Sometimes I just need a quick and dirty (somewhat typesafe) program which gets the job done - sometimes its js, sometimes a tool in console, sometimse web/client code (also smartphone applets). comes close, but while the language is fun to use it still has some shortcomings - and sometimes I hit unexpected bugs. The real question I have is: - Haskell is cool - being lazy is cool - having OO is cool (because you can target Java/Flash/.. easily) - how to get best of all worlds? So I think about creating my own language is should look like more like a source code generator than language which contains different sub universes. The idea is to code some parts - such as a parser - in a Haskell like dialect, then reuse it in quick and dirty OO world (Java like). Of course additional targets could be just plain old C, because C++ is known to be very complex - and there are tons of legacy code which should
Categories: Offsite Discussion

Enabling TypeHoles by default

glasgow-user - Mon, 01/13/2014 - 8:42pm
Hello, As discussed on ghc-devs, I propose to enable -XTypeHoles in GHC by default. Rationale: (1) This way holes are far easier to use; just entering "_" allows to check type of a subexpression, no need of adding "-XTypeHoles". (2) This affects error messages only; i.e. the set of programs that compile stays the same - Haskell 2010. The only exception is that if you use -fdefer-type-errors, then a program with a hole compiles, but this seems fine with philosophy of -fdefer-type-errors. If so: would you like it to be in 7.8 or wait a cycle? My preference is 7.8, two people (John and Richard) suggested 7.10. -KG _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users< at >
Categories: Offsite Discussion

Edward Z. Yang: Ott ⇔ PLT Redex

Planet Haskell - Mon, 01/13/2014 - 6:11pm

Ott and PLT Redex are a pair of complimentary tools for the working semanticist. Ott is a tool for writing definitions of programming languages in a nice ASCII notation, which then can be typeset in LaTeX or used to generate definitions for a theorem prover (e.g. Coq). PLT Redex is a tool for specifying and debugging operational semantics. Both tools are easy to install, which is a big plus (cough K Framework cough). Since the tools are quite similar, I thought it might be interesting to do a comparison of how various common tasks are done in both languages. (Also, I think the Redex manual is pretty terrible.)

Variables. In Ott, variables are defined by way of metavariables (metavar x), which then serve as variable (by either using the metavariable alone, or suffixing it with a number, index variable or tick).

In Redex, there is no notion of a metavariable; a variable is just another production. There are a few different ways say that a production is a variable: the simplest method is to use variable-not-otherwise-mentioned, which automatically prevents keywords from acting as variables. There are also several other variable patterns variable, variable-except and variable-prefix, which afford more control over what symbols are considered variables. side-condition may also be useful if you have a function which classifies variables.

Grammar. Both Ott and Redex can identify ambiguous matches. Ott will error when it encounters an ambiguous parse. Redex, on the other hand, will produce all valid parses; while this is not so useful when parsing terms, it is quite useful when specifying non-deterministic operational semantics (although this can have bad performance implications). check-redundancy may be useful to identify ambiguous patterns.

Binders. In Ott, binders are explicitly declared in the grammar using bind x in t; there is also a binding language for collecting binders for pattern-matching. Ott can also generate substitution/free variable functions for the semantics. In Redex, binders are not stated in the grammar; instead, they are implemented solely in the reduction language, usually using substitution (Redex provides a workhorse substitution function for this purpose), and explicitly requiring a variable to be fresh. Redex does have a special-form in the metalanguage for doing let-binding (term-let), which substitutes immediately.

Lists. Ott supports two forms of lists: dot forms and list comprehensions. A dot form looks like x1 , .. , xn and requires an upper bound. A list comprehension looks like </ xi // i IN 1 .. n />; the bounds can be omitted. A current limitation of Ott is that it doesn’t understand how to deal with nested dot forms, this can be worked around by doing a comprension over a production, and then elsewhere stating the appropriate equalities the production satisfies.

Redex supports lists using ellipsis patterns, which looks like (e ...). There is no semantic content here: the ellipses simply matches zero or more copies of e, which can lead to nondeterministic matches when there are multiple ellipses. Nested ellipses are supported, and simply result in nested lists. Bounds can be specified using side-conditions; however, Redex supports a limited form of bounding using named ellipses (e.g. ..._1), where all ellipses with the same name must have the same length.

Semantics. Ott is agnostic to whatever semantics you want to define; arbitrary judgments can be specified. One can also define judgments as usual in Redex, but Redex provides special support for evaluation semantics, in which a semantics is given in terms of evaluation contexts, thus allowing you to avoid the use of structural rules. So a usual use-case is to define a normal expression language, extend the language to have evaluation contexts, and then define a reduction-relation using in-hole to do context decomposition. The limitation is that if you need to do anything fancy (e.g. multi-hole evaluation contexts), you will have to fall back to judgment forms.

Type-setting. Ott supports type-setting by translation into LaTeX. Productions can have custom LaTeX associated with them, which is used to generate their output. Redex has a pict library for directly typesetting into PDF or Postscript; it doesn’t seem like customized typesetting is an intended use-case for PLT Redex, though it can generate reasonable Lisp-like output.

Conclusion. If I had to say what the biggest difference between Ott and PLT Redex was, it is that Ott is primarily concerned with the abstract semantic meaning of your definitions, whereas PLT Redex is primarily concerned with how you would go about matching against syntax (running it). One way to see this is in the fact that in Ott, your grammar is a BNF, which is fed into a CFG parser; whereas in PLT Redex, your grammar is a pattern language for the pattern-matching machine. This should not be surprising: one would expect each tool’s design philosophy to hew towards their intended usage.

Categories: Offsite Blogs

High level overview of GHCi?

haskell-cafe - Mon, 01/13/2014 - 2:45pm
Dear Café, I was reading Figure 5.2 gives a high level overview of the compiler passes when compiling Haskell with GHC. Is anyone aware of a similar figure that gives an overview of the passes when Haskell code is interpreted with GHCi? Thank you! Maarten Faddegon
Categories: Offsite Discussion