Skip to content

Instantly share code, notes, and snippets.

var listSelectors = require('list-selectors');
var fs = require('fs')
module.exports = function(elmsource) {
function makeLine(prefixedName) {
const name = prefixedName.substr(1)
return `${name} = "${name}"`
}
%default total
p_implies_p : p -> p
p_implies_p x = x
data And a b = MkAnd a b
data Or a b = Left a | Right b
p_implies_p_and_p : p -> And p p
module Child exposing (init, update, Message(InterestingMessage))
init = 0
type Message
= InterestingMessage
| InternalMessage
update message model = model
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
uint64_t water_on_pillars(uint64_t pillars[], size_t len) {
if (len < 3) {
return 0;
}
typeSignature =
lazy <| \() ->
sepBy (whitespace *> string "->" *> whitespace) nonFunctionType
|> andThen (
reducer TArrow
>> Maybe.map succeed
>> Maybe.withDefault (fail "expected type, got nothing")
)
reducer : (a -> a -> a) -> List a -> Maybe a
typeSignature =
lazy <| \() ->
sepBy (whitespace *> string "->" *> whitespace) nonFunctionType
|> andThen (
reducer TArrow
>> Maybe.map succeed
>> Maybe.withDefault (fail "expected type, got nothing")
)
reducer : (a -> a -> a) -> List a -> Maybe a
@joonazan
joonazan / gist:bb52254a63f774600b49ca4d14527bf6
Created April 17, 2017 13:20
buggy recursion in parser
typeSignature =
lazy <| \() ->
sepBy (whitespace *> string "->" *> whitespace) nonFunctionType
|> andThen (
reducer TArrow
>> Maybe.map succeed
>> Maybe.withDefault (fail "expected type, got nothing")
)
reducer : (a -> a -> a) -> List a -> Maybe a
@joonazan
joonazan / ParseLibrary.elm
Created April 15, 2017 17:56
Invalid recursion in Elm 0.18 still causes runtime error
module ParseLibrary exposing (typeSignature)
import Combine exposing (..)
import Dict exposing (Dict)
type Type
= TArrow Type Type
| TName String
| TRecord (Dict String Type)
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int n;
int *aita;
void print_solution(int tertiary){
module Child exposing (init, update, Message(InterestingMessage))
init = 0
type Message
= InterestingMessage
| InternalMessage
update message model = model